Style height attribute
- Vorherige Seite fontSizeAdjust
- Nächste Seite isolation
- Zurück zur vorherigen Ebene HTML DOM Style-Objekt
Definition and usage
height
Sets or returns the height of the element.
height
The attribute is only valid for block-level elements or elements with absolute or fixed positions. Overflowing content can be Overflow attribute to operate.
Tip:Use Width attribute Sets or returns the width of the element.
See also:
CSS Tutorial:CSS Dimension
CSS Tutorial:CSS-Fensterrahmenmodell
CSS Reference Manual:Height attribute
Example
Example 1
Set the height of the <button> element:
document.getElementById("myBtn").style.height = "50px";
Example 2
Change the height of the <div> element:
document.getElementById("myDIV").style.height = "500px";
Example 3
Change the height and width of the <img> element:
document.getElementById("myImg").style.height = "300px"; document.getElementById("myImg").style.width = "300px";
Example 4
Return the height of the <img> element:
alert(document.getElementById("myImg").style.height);
Syntax
Return the height attribute:
object.style.height
Set the height attribute:
object.style.height = "auto|length|%|initial|inherit"
Attribute value
Value | Description |
---|---|
auto | Browser sets the height. Default. |
length | Define the height with a length unit. |
% | Defined by the percentage of the parent element's height. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | auto |
---|---|
Return value: | A string representing the height of the element. |
CSS Version: | CSS1 |
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
- Vorherige Seite fontSizeAdjust
- Nächste Seite isolation
- Zurück zur vorherigen Ebene HTML DOM Style-Objekt