Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Box Model and Sizing

The min-height property

Reference for the CSS min-height property: set a floor under an element's height, build full-viewport sections and sticky footers, and avoid fixed-height overflow.

The min-height property sets a lower limit for an element's height. The box can still grow taller when its content needs more room, but it will never be shorter than this value. That is the safe alternative to a fixed height: it guarantees a minimum size for the design without clipping or overflowing text.

Common uses are hero sections that fill the screen, equal-looking cards, and pages whose footer should reach the bottom even when the content is short.

CSS
.hero { min-height: 100vh; }
.card { min-height: 8rem; }

Try it

Grow with content, never shrink below the floor
Sticky footer with min-height

Syntax

CSS
min-height: auto
          | <length-percentage [0,โˆž]>
          | min-content | max-content | fit-content | fit-content(<length-percentage>)
          | stretch;
  • Initial value: auto
  • Applies to: all elements except non-replaced inline elements, table columns and column groups
  • Inherited: no
  • Animatable: yes, as a length or percentage
  • Computed value: a percentage or auto as specified, otherwise an absolute length

Values

Value Description
auto 0 for ordinary boxes. For flex and grid items it is the content-based minimum size.
<length> A fixed floor such as 200px, 10rem or 100vh.
<percentage> A percentage of the containing block's height, resolved only if that height is definite; otherwise it acts like 0.
min-content, max-content, fit-content Content-based floors.
stretch Fill the container's available height. Newer, limited support.

Usage notes

  • Prefer it over height for any box with text or user-generated content.
  • min-height: 100vh makes a section at least as tall as the viewport. On phones use 100dvh so toolbars do not push content under the screen edge.
  • Percentages need a definite parent height. min-height: 100% on <body> works only if html has a height too. Flex layout avoids the problem.
  • Flex and grid items. min-height: auto can stop a scrolling flex child from shrinking; set min-height: 0 on the item that should scroll.
  • min-height beats height and max-height when they conflict.
  • Logical equivalent: min-block-size.

Browser support

Supported in every browser. Dynamic viewport units like dvh work in all current browsers.