HTML DOM Element clientHeight Property
- Previous Page click()
- Next Page clientLeft
- Go Back to the Previous Level HTML DOM Elements Object
Definition and Usage
clientHeight
The property returns the visible height of the element, including padding, but not including borders, scrollbars, or margins, in pixels.
clientHeight
The property is read-only.
See Also:CSS Box Model Tutorial
See Also:
To add a scrollbar to an element, please use CSS Overflow Property.
Example
Example 1
Get the height and width of "myDIV", including padding:
const element = document.getElementById("myDIV"); let text = "clientHeight: " + element.clientHeight + "px<br>"; text += "clientWidth: " + element.clientWidth + "px";
Example 2: Difference between clientHeight/clientWidth and offsetHeight/offsetWidth
Without Scrollbar:
const element = document.getElementById("myDIV"); let text = ""; text += "clientHeight: " + element.clientHeight + "px<br>"; text += "offsetHeight: " + element.offsetHeight + "px<br>"; text += "clientWidth: " + element.clientWidth + "px<br>"; text += "offsetWidth: " + element.offsetWidth + "px";
With Scrollbar:
const element = document.getElementById("myDIV"); let text = ""; text += "clientHeight: " + element.clientHeight + "px<br>"; text += "offsetHeight: " + element.offsetHeight + "px<br>"; text += "clientWidth: " + element.clientWidth + "px<br>"; text += "offsetWidth: " + element.offsetWidth + "px";
Syntax
element.clientHeight
Return Value
Type | Description |
---|---|
Number | The visible height of the element (in pixels), including padding. |
Browser Support
All browsers support element.clientHeight
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page click()
- Next Page clientLeft
- Go Back to the Previous Level HTML DOM Elements Object