๐Ÿฆถ CSS

The Sticky Footer Problem โ€” Solved in 3 Lines (Finally)

๐Ÿ“… Jul 3, 2026 โฑ 2 min read

Short page โ†’ footer floats mid-screen with awkward space below. A 15-year-old problem with a 3-line modern answer.

The flexbox solution

body {
  min-height: 100vh;          /* at least full screen (100dvh for mobile) */
  display: flex;
  flex-direction: column;
}
main { flex: 1; }             /* main absorbs the spare space */
/* header + footer keep natural height; footer lands at the bottom */

The grid version

body {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;   /* header | main | footer */
}

Notes

This site uses the flex version โ€” inspect body and see.

โ† All Articles