Style maxHeight Property
Example
Set the maximum height of a <div> element:
document.getElementById("myDIV").style.maxHeight = "15px";
Try it yourself »
Definition and Usage
The maxHeight property sets or returns the maximum height of an element.
The maxHeight property has effect only on block-level elements or on elements with absolute or fixed position.
Note: The height of an element can never be greater than the value specified by the maxHeight property.
Tip: To set or return the minimum height of an element, use the minHeight property.
Browser Support
The maxHeight property is supported in all major browsers.
Syntax
Return the maxHeight property:
object.style.maxHeight
Set the maxHeight property:
object.style.maxHeight="none|length|%|initial|inherit"
Property Values
Value | Description |
---|---|
none | No limit on the height of the element. This is default |
length | Defines the maximum height in length units |
% | Defines the maximum height in % of the parent element |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technical Details
Default Value: | none |
---|---|
Return Value: | A String, representing the maximum height of an element |
CSS Version | CSS2 |
More Examples
Example
Return the maximum height of a <div> element:
alert(document.getElementById("myDIV").style.maxHeight);
Try it yourself »
Related Pages
CSS tutorial: CSS Dimension
CSS reference: max-height property
Style Object