← all articles
// article

Sticky footer — solving without flexbox hacks

2026-04-11

The Unstuck Footer: A Common Design Frustration

Ah, the elusive footer. It's supposed to sit comfortably at the bottom of your page, a steadfast anchor. Yet, too often, on pages with minimal content, it drifts upwards, leaving an awkward, empty void of whitespace beneath it. This isn't just an aesthetic quibble; it subtly undermines the professionalism of your digital presence. But how do you keep it down there without wrestling with CSS properties that feel less like solutions and more like elaborate workarounds?

The most elegant, no-hack solution for a sticky footer without resorting to complex flexbox manipulations or outdated positioning tricks is a concise application of CSS Grid. Specifically, applying display: grid; and grid-template-rows: auto 1fr auto; to your main page wrapper or the <body> element, coupled with a minimal min-height: 100vh;, provides a robust and clean fix.

Why Does a Footer Need to "Stick" Anyway?

You might wonder if this is just pixel-pushing for the sake of it. It's not. A properly sticky footer contributes significantly to a website's perceived quality and user experience. Consider these points:

The Old Ways: Why "Hacks" Weren't Solutions

For years, developers have twisted CSS into knots trying to achieve a sticky footer. Some popular (and often problematic) approaches included:

These methods, while they got the job done, were often fragile, hard to maintain, and lacked the declarative elegance that modern CSS now offers. They felt like hacks because they required understanding several interconnected, sometimes counter-intuitive, properties to achieve a seemingly simple layout goal.

CSS Grid: The Straightforward, Declarative Approach

Enter CSS Grid. Designed for two-dimensional layouts, it provides an incredibly intuitive and robust way to define the overall structure of your page. For a sticky footer, it's almost laughably simple.

Here's the core idea:

  1. Make your main page container (typically the <body> or a <div> wrapper) a Grid container.
  2. Define three rows: one for the header, one for the main content, and one for the footer.
  3. Tell the content row to take up all available space, pushing the footer to the bottom.

The HTML Structure:

Your HTML might look something like this:

<body>
  <header>...</header>
  <main>...</main>
  <footer>...</footer>
</body>

Or, if you prefer a wrapper:

<div class="page-wrapper">
  <header>...</header>
  <main>...</main>
  <footer>...</footer>
</div>

The CSS Magic:

html,
body {
  height: 100%; /* Important for body to fill viewport */
  margin: 0; /* Remove default body margin */
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto; /* Header, Content, Footer */
  min-height: 100vh; /* Ensure it's at least viewport height */
}

/* If using a wrapper instead of body */
/*
.page-wrapper {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}
*/

/* Ensure main content takes up remaining space */
main {
  grid-row: 2;
}

/* You might need to explicitly assign header/footer if not direct children of body/wrapper or if you want specific grid areas */
header {
  grid-row: 1;
}

footer {
  grid-row: 3;
}

Let's break down grid-template-rows: auto 1fr auto;:

The min-height: 100vh; on the <body> (or .page-wrapper) is crucial. It ensures that the Grid container itself is at least the full height of the viewport. Without it, if your content is short, the grid might collapse, and the 1fr wouldn't have any extra space to claim.

This approach is clean, highly readable, and leverages the intended power of CSS Grid. Browser support for Grid is excellent across all modern browsers, making it a safe bet for any new or existing project. At SISL, we lean heavily on modern CSS like Grid for exactly this kind of clean, maintainable solution, ensuring our clients' websites are built on robust foundations.

When a Sticky Footer Isn't the Right Choice

While often beneficial, a sticky footer isn't a universal panacea. There are scenarios where it might hinder rather than help:

Beyond the Sticky Footer: Maintainable CSS

The sticky footer problem, and its elegant CSS Grid solution, is a microcosm of a larger principle: using the right tool for the job. Modern CSS, with Grid, Flexbox, and Custom Properties, provides incredibly powerful and intuitive ways to build complex layouts without resorting to hacks or convoluted workarounds. This not only speeds up development but dramatically improves maintainability, making future updates and changes far less painful.

For SME owners, freelancers, and startup founders, this translates directly to cost savings and a more resilient online presence. A website built with clean, semantic, and maintainable CSS is less prone to bugs, loads faster, and provides a better experience for your users. It means less time troubleshooting obscure layout issues and more time focusing on your core business.

If your current website feels like it's held together by sticky tape and CSS 'hacks,' or if you're spending too much time battling your layout, perhaps it's time for a conversation. Our approach focuses on robust, future-proof foundations that just work. You can always get in touch with us to discuss how we can bring clarity and stability to your web projects.

The sticky footer, once a source of constant frustration, is now a testament to the power and simplicity of modern CSS. Embrace Grid, and banish those floating footers for good.

Got a similar problem?

Boutique web development studio from Poland — sites, WooCommerce / Magento stores, custom web apps and landings. See what we shipped.

See SISL portfolio →

Free technical audit of your site — in 24h

Core Web Vitals measured on real users, indexability, structured data, meta and internal linking. A written report with prioritised fixes, not a PDF from a generic tool. No cost, no call required.

Get the free audit →