avinash majhi avinash majhi - 1 year ago 100
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download