We can use the HTML DOM element object and it’s properties to get the height and width of any element. In the HTML DOM Element object is represented by an HTML element, for e.g. p, div, table, a, section, etc.
To get the height of any element we can use scrollHeight property and to get width of the element we can use scrollWidth property.
The scrollHeight property returns the height of an element in pixels. The returned height includes padding, but it doesn’t include the border, margin or scrollbar.
The scrollWidth property returns the width of an element in pixels. The returned width includes padding, but it doesn’t include the border, margin or scrollbar.
Both scrollHeight and scrollWidth properties are read only.