clientHeight in javascript

clientHeight property in javascript

clientHeight property is used to find the inner height of an element.

If the element doesn't contain any CSS or inline layout boxes, it returns zero.

This property calculates the height as, CSS height + CSS padding - height of horizontal scroll bar.

Syntax

var elem = element.clientHeight;

Example - Get clientHeight of an element

Try Yourself

Example Explanation

  • In the above example we have created a div (idDiv), and have specified height and padding for the element.
  • When the button is clicked, fun_name function is called.
  • In the Javascript function, first we are getting the element (document.getElementById("idDiv")) and storing it in elem variable.
  • Using the clientHeight property, the height is calculated and displayed (alert(elem.clientHeight)).