avinash majhi avinash majhi - 2 months ago 11x
CSS Question

How to get inner HTML content height

I want to get inner html height by JavaScript. Suppose I have


either if the div font size has increased or many divs nested inside the parent, how do I get the height of parent div?

edit: even if the nested div has border and padding too.


If it must be in vanilla JS...

var height = document.getElementById('content').clientHeight;

That will include any borders or scrollbars in the element. If you want JUST the inner HTML (excluding the padding), you may use offsetHeight instead.