How to get inner HTML content height

Use clientHeight and getElementsByTagName div to get spcific div height

document.getElementsByTagName('div')[0].clientHeight

http://codepen.io/nagasai/pen/XKoxZw


If it must be in vanilla JS...

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

That will not include any borders or scrollbars in the element, just padding. If you want to include borders and scrollbars you may use offsetHeight instead.


The accepted answer is incorrect in the case that the parent element has a height of 0, and you want the height of the content within it (which is what I believe the OP was asking for). In that case, scrollHeight is the property you want.

const divInnerContentHeight = document.querySelector('div').scrollHeight;

Using clientHeight or offsetHeight would return 0;


Something like this?

<div id="MyDiv">Content</div>

console.log(document.getElementById("MyDiv").offsetHeight);