spacing

height

Sets the vertical size of an element. Viewport units like vh, dvh, and svh are common for full-screen sections and account for mobile browser chrome.

height: auto | <length> | <percentage> | min-content | max-content | fit-content

Common values

Value Effect
auto Default; height derived from content
100vh Full viewport height
100dvh Dynamic viewport height, adjusts to mobile UI
100% Percentage of parent's height
fit-content Shrinks to content, capped by container

Examples

.hero { height: 100dvh; }

Full-screen hero that respects mobile bars

.avatar { height: 40px; width: 40px; }

Fixed-size circular avatar

.panel { height: 100%; }

Panel stretches to parent's height

Gotcha

height: 100% only works if every ancestor has a defined height; use min-height or viewport units for full-page sections.

Related properties

← All CSS properties · CSS selectors · Grid vs Flexbox