# Flexbox Sticky Footer

> Keeps the footer at the bottom of short pages with a flex column and margin-top: auto on the footer.

- Category: [CSS Layouts](https://copy-css.com/category/layouts)
- Tags: footer, margin-top auto, flex column, full height, page
- Live preview: https://copy-css.com/snippets/flexbox-sticky-footer
- License: Free for personal and commercial use. No signup, no attribution required.

## HTML

```html
<div class="flex-page">
  <header>Header</header>
  <main>Short content</main>
  <footer>Footer</footer>
</div>
```

## CSS

```css
.flex-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Pushes the footer down, however many elements come before it */
.flex-page > footer {
  margin-top: auto;
}
```

## Notes

- This CSS Flexbox Sticky Footer is 11 lines of pure CSS (0.2 KB) with no JavaScript and no dependencies. It uses Flexbox.
- In JSX use `className` instead of `class`. In Tailwind projects put the CSS in the global stylesheet.
