HTML DOM clientHeight property
Example
Get the height of the div element, including padding:
var
elmnt
=
document
.
getElementById
(
"
myDIV
"
)
;
var
txt
=
"
The height of the div element, including padding:
"
elmnt
.
clientHeight
"
px
"
;
txt
+=
"
The width of the div element, including padding:
"
elmnt
.
clientWidth
"
px
"
;
Try it »
Definition and Usage
The clientHeight property is a read-only property that returns the pixel height of the element, including padding but not the border, margin or scrollbar; it is an integer measured in pixels (px).
clientHeight can be calculated as CSS height + CSS padding - horizontal scrollbar height (if present).

For the document's body object, it includes the total CSS height of the replaced elements linearly. The downward-extending content height of floating elements is ignored.
Note: To understand this property, you can refer to CSS Box Model.
Tip: This property is usually used together with the clientWidth property.
Tip: Use offsetHeight and offsettWidth The property returns the visible height and width of the element, including padding and border.
Tip: To add a scrollbar to an element, you can use overflow attribute.
This is a read-only property.

Browser support
| property | |||||
|---|---|---|---|---|---|
| clientHeight | Yes | Yes | Yes | Yes | Yes |
Syntax
element.clientHeight
Technical Details
| Return Value: | Returns an integer representing the pixel height of the element. |
|---|
More examples
Example
The following example demonstrates the difference between the clientHeight/clientWidth and offsetHeight/offsetWidth properties:
var
elmnt
=
document
.
getElementById
(
"
myDIV
"
)
;
var
txt
=
"
"
;
txt
+=
"
The height includes padding:
"
elmnt
.
clientHeight
"
px
"
;
txt
+=
"
The height includes padding and border:
"
elmnt
.
offsetHeight
"
px
"
;
txt
+=
"
The width includes padding:
"
elmnt
.
clientWidth
"
px
"
;
txt
+=
"
The width includes padding and border:
"
elmnt
.
offsetWidth
"
px
"
;
Try it »
Example
The following example demonstrates the difference between the clientHeight/clientWidth and offsetHeight/offsetWidth properties after a scrollbar is added to the element:
var
elmnt
=
document
.
getElementById
(
"
myDIV
"
)
;
var
txt
=
"
"
;
txt
+=
"
The style information of the div:
"
;
txt
+=
"
The height includes padding:
"
elmnt
.
clientHeight
"
px
"
;
txt
+=
"
The height includes padding, border and scrollbar:
"
elmnt
.
offsetHeight
"
px
"
;
txt
+=
"
The width includes padding:
"
elmnt
.
clientWidth
"
px
"
;
txt
+=
"
The width includes padding, border and scrollbar:
"
elmnt
.
offsetWidth
"
px
"
;
Try it »
Element object