The property styleis different from the actual style in CSS: it is looking for an attribute style, so this is:
<p style="height: 100px"></p>
<script>alert(document.getElementsByTagName("p")[0].style.height);</script>
will be "100px".
To get the actual height, use getComputedStyle().
<style> p { height: 100px; }</style>
<p></p>
<script>alert(getComputedStyle(document.getElementsByTagName("p")[0]).getPropertyValue("height"));</script>
source
share