CSSmax-height Property
Example
Set the maximum height of a <p> element to 50 pixels:
max-height: 50px;
}
Definition and Usage
Themax-height property defines the maximum height of an element.
If the content is larger than the maximum height, it will overflow. How the container will handle the overflowing content is defined by theoverflow property.
If the content is smaller than the maximum height, themax-height property has no effect.
Note: This prevents the value of theheight property from becoming larger thanmax-height. The value of themax-height property overridesthe height property.
| Default value: | none |
|---|---|
| Inherited: | no |
| Animatable: | yes,see individual properties.Read aboutanimatableTry it |
| Version: | CSS2 |
| JavaScript syntax: | object.style.maxHeight="100px"Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
| Property | |||||
|---|---|---|---|---|---|
| max-height | 1.0 | 7.0 | 1.0 | 1.3 | 7.0 |
CSS Syntax
Property Values
| Value | Description | Demo |
|---|---|---|
| none | No maximum height. This is default | Play it » |
| length | Defines the maximum height in px, cm, etc.Read about length units | Play it » |
| % | Defines the maximum height in percent of the containing block | |
| initial | Sets this property to its default value.Read aboutinitial | |
| inherit | Inherits this property from its parent element.Read aboutinherit |
Related Pages
CSS tutorial:CSS Height and Width
CSS reference:min-height property
HTML DOM reference:maxHeight property

