clientHeight property

The clientHeight property contains the height of an element inside borders along with padding, but without border and scroll.

Syntax

javascriptelement.clientHeight;

Example

Let's find the size of an element:

css#elem {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  padding: 15px;
}
html<div id="elem"></div>
javascriptlet elem = document.querySelector('#elem');
console.log(elem.clientHeight);

The code execution result:

javascript130

Example

If an element has a scroll, then the width of a content is reduced by the width of a scroll (about 16px - depends on the browser, OS, device). In the following example, the width of an element will be smaller than expected:

html<div id="elem">This element has a scroll.</div>
css#elem {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  padding: 15px;
  overflow: scroll;
}
javascriptlet elem = document.querySelector('#elem');
console.log(elem.clientHeight);

The code execution result:

javascript114 (depends on the browser)

Example

If an element is hidden, then clientHeight will be equal to 0:

html<div id="elem"></div>
css#elem {
  width: 100px;
  height: 100px;
  border: 1px solid black;
  display: none; /* hidden element */
}
javascriptlet elem = document.querySelector('#elem');
console.log(elem.clientHeight);

The code execution result:

javascript0

See also

  • the clientWidth property
    that contains the width of an element inside borders
  • the getComputedStyle method
    that gets the value of an element's CSS property