Style maxHeight Attribute
- Föregående sida marginTop
- Nästa sida maxWidth
- Gå tillbaka till föregående nivå HTML DOM Style Object
Definition and Usage
maxHeight
Sets or returns the maximum height of an element.
maxHeight
The attribute is only valid 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 attribute.
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"
Attribute value
Value | Description |
---|---|
none | The height of the element is not limited. Default. |
length | Define the maximum height in length units. |
% | Define the maximum height in percentage of the parent element. |
initial | Set this property to its default value. See initial. |
inherit | Inherit 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 |
Webbläsarstöd
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Stöd | Stöd | Stöd | Stöd | Stöd |
- Föregående sida marginTop
- Nästa sida maxWidth
- Gå tillbaka till föregående nivå HTML DOM Style Object