Maximum height

max-height

Specify the maximum height for elements that automatically change their size.

Property values

This value will be used when the text of an element is so long that it doesn't completely fit within the normal height for the element. The element's height will expand up to the amount of space required to fit everything.

If that expanded height is less than the max-height property, the element's actual height is set to that expanded value (somewhere between height and max-height).

When the expanded height is more than the value specified for max-height, the element's height is capped at max-height, and the extra text is subject to the overflow-y rule, either causing a vertical scrollbar to appear or causing the overflowed text to be hidden.

Units

Use any of these font-relative typographic units to set the element's maximum height:

em em The font-size of the current font
rem relative em The font-size of the <html> element
lh line height The line-height of the current font
rlh relative line height The line-height of the <html> element
cap cap height The nominal height of the current font's capital letters
ex "x" The height of the current font's "x" glyph

Or use any of these fixed size units which are independent of the current font:

% percent A percentage of the parent element's height
in inch A size equal 96px
px pixels A size equal to 1/96 inch
pt point A size equal 1in/72 = 1.33px
pc pica A size equal 1in/6 = 12pt = 16px
cm centimeter A size equal to 96px/2.54 = 37.8px
mm millimeter A size equal to 96px/25.4 = 3.8px
Q quarter millimeter A size equal to 96px/1016 = 0.94px

Or use these viewport-percentage units which account for different display device capabilities:

vh viewport height 1% of the viewport's height
vw viewport width 1% of the viewport's width
vi viewport inline axis 1% of the viewport's inline axis
vb viewport block axis 1% of the viewport's block axis
vmin viewport minimum Either vh or vw, whichever is smaller
vmax viewport maximum Either vh or vw, whichever is larger

Examples

max-height: 80%;
max-height

style > sizing > max-heightMaximum height

Q