max-height
Sets the maximum height of an element. It prevents the element from becoming taller than the specified value. If the content is taller, it will overflow based on the overflow property.
Quick example
.scrollable-box {
max-height: 300px;
overflow-y: auto;
/* caps the height and adds a scrollbar if content exceeds 300px */
} Quick facts
Initial value
noneInherited
No
Applies to
all elements but non-replaced and table columns
Animation type
lpc
Values
nonelength-percentagemin-contentmax-contentfit-contentcalc-sizeanchor-size max-height Browser Support
Widely available Since 2015 96% global usage
This feature is well established and works across many devices and browser versions. It has been available across browsers since 2015.
Safe to use without fallbacks.
1+
1+
1.3+
12+