Find out the height of an element through Javascript, if it is written in a style file


How can I get the height attribute of an element via Javascript if it is written in the style.css file?


.menu_bottom {
    height: 100px;


<div id="menu_bottom" class="menu_bottom">
    <script type="text/Javascript">

You want the alert(...) message to show the height of the given element (just a number, no unit).


the easiest is to use jQuery :


without jQuery you can use:

var h = document.getElementById('menu_bottom').clientHeight;
var h = document.getElementById('menu_bottom').offsetHeight;
var h = document.getElementById('menu_bottom').scrollHeight;

clientHeight is the height of the content along with the padding, but no scrollbar.

offsetHeight is the "outer" height of the box, including borders.

scrollHeight is the full inner height, including the scrolled area.

Scroll to Top