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.
.hero { min-height: 100vh; } .card { min-height: 8rem; }
Try it
Syntax
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
autoas 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
heightfor any box with text or user-generated content. min-height: 100vhmakes a section at least as tall as the viewport. On phones use100dvhso toolbars do not push content under the screen edge.- Percentages need a definite parent height.
min-height: 100%on<body>works only ifhtmlhas a height too. Flex layout avoids the problem. - Flex and grid items.
min-height: autocan stop a scrolling flex child from shrinking; setmin-height: 0on the item that should scroll. min-heightbeatsheightandmax-heightwhen they conflict.- Logical equivalent:
min-block-size.
Browser support
Supported in every browser. Dynamic viewport units like dvh work in all current browsers.
Related
heightโ preferred heightmax-heightโ upper limitmin-widthโ the horizontal floorblock-sizeโ logical size- Lesson: Width and Height
- Lesson: Viewport Units