Style maxHeight Property
- Previous Page marginTop
- Next Page maxWidth
- Go to the Previous Level HTML DOM Style Object
Definition and Usage
maxHeight
Sets or returns the maximum height of an element.
maxHeight
The property is only effective for block-level elements or elements with absolute or fixed positioning.
Note:The height of the element can never be greater than maxHeight
The value specified by the property.
Tip:To set or return the minimum height of an element, use minHeight Property.
See Also:
CSS Tutorial:CSS Dimension
CSS Reference Manual:max-height Property
Example
Example 1
Set the maximum height of the <div> element:
document.getElementById("myDIV").style.maxHeight = "15px";
Example 2
Return the maximum height of the <div> element:
alert(document.getElementById("myDIV").style.maxHeight);
Syntax
Return maxHeight Property:
object.style.maxHeight
Set maxHeight Property:
object.style.maxHeight = "none|length|%|initial|inherit"
Property Value
Value | Description |
---|---|
none | The height of the element is not restricted. Default. |
length | Defined by a length unit. |
% | Defined by the percentage of the parent element. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default Value: | None |
---|---|
Return Value: | A string that represents the maximum height of an element. |
CSS Version: | CSS2 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page marginTop
- Next Page maxWidth
- Go to the Previous Level HTML DOM Style Object