Bogdan
Bogdan

Reputation: 1911

How come these two alerts showing the height and offsetheight of the same element don't display the same number?

the alerts are as follows:

alert(document.getElementById("col_st_scroll").offsetHeight);
alert(document.getElementById("col_st_scroll").style.height);

now, the col_st_scroll element is fully visible in the web browser, shouldn't that mean offsetHeight and style.height should returnt he same value?

problem solved. The element was resized by another function in the time it took to click ok ont he first alert.

Upvotes: 0

Views: 128

Answers (1)

bfavaretto
bfavaretto

Reputation: 71918

This is from MDN:

Typically, an element's offsetHeight is a measurement which includes the element borders, the element vertical padding, the element horizontal scrollbar (if present, if rendered) and the element CSS height.

The style.height property represents the content height only (assuming you're on "strict" rendering mode, not "quirks").

Upvotes: 1

Related Questions