CSS max-height Property

Set the maximum height of a <p> element:

p {
max-height: 50px;
}

Try it Yourself »


Definition and Usage

The max-height property is used to set the maximum height of an element.

This prevents the value of the height property from becoming larger than max-height.

Note: The value of the max-height property overrides height.

Default value: none
Inherited: no
Animatable: yes, see individual propertiesRead about animatable – Try it
Version: CSS2
JavaScript syntax: object.style.maxHeight=”100px” Try it
CSS Syntax
max-height: none|length|initial|inherit;
Property Values
Value Description
none No maximum height. This is default
length Defines the maximum height in px, cm, etc.
% Defines the maximum height in percent of the containing block
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit