1. Home
  2. Javascript
  3. Element width and height

You can use 'client' and 'offset' variants of width and height properties to get the dimensions of elements. The 'clientWidth' and 'clientHeight' properties capture element sizes including padding only. The 'offsetWidth' and 'offsetHeight' properties capture the full size of the element including padding, margin and border.

#javascript#element
// Element sizes including padding
element.clientHeight;
element.clientWidth;

// Element sizes including padding, margin and border
element.offsetHeight;
element.offsetWidth;
copy
Full Javascript cheatsheet