HTMLElement.offsetHeight

This article is in need of a technical review.

« HTMLElement

The HTMLElement.offset read-only property is the height of an element relative to the element's HTMLElement.offsetParent.

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.

Non-scrollable elements (CSS overflow not set or set to visible) will have equal offsetHeight and Element.scrollHeight (is this right? scrollHeight doesn't include the border, while offsetHeight would include border).

For the document body object, the measurement includes total linear content height instead of the element CSS height. Floated elements extending below other linear content are ignored.

This property will round the value to an integer. If you need a fractional value, use element.getBoundingClientRect().

Syntax

var intElemOffsetHeight = document.getElementById(id_attribute_value).offsetHeight;

intElemOffsetHeight is a variable storing an integer corresponding to the offsetHeight pixel value of the element. offsetHeight is a read-only property.

Example

padding-top

Gentle, individualistic and very loyal, Birman cats fall between Siamese and Persian in character. If you admire cats that are non aggressive, that enjoy being with humans and tend to be on the quiet side, you may well find that Birman cats are just the felines for you.

Image:BirmanCat.jpgAll Birmans have colorpointed features, dark coloration of the face, ears, legs and tail.

Cat image and text coming from www.best-cat-art.com

padding-bottom

LeftTopRightBottommargin-topmargin-bottomborder-topborder-bottom[if IE]><span id="MrgLeft" style="position: _fckstyle="position: _fckstyle="position: _fckstyle="position: _fckstyle="position: _fckstyle="position: _fckstyle="position: _fckstyle="position: absolute; left: 8px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-left</span><span id="BrdLeft" style="position: absolute; left: 33px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-left</span><span id="PdgLeft" style="position: absolute; left: 55px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">padding-left</span><span id="PdgRight" style="position: absolute; left: 275px; top: 60px; color: black; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl; white-space: nowrap;">padding-right</span><span id="BrdRight" style="position: absolute; left: 310px; top: 65px; color: white; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">border-right</span><span id="MrgRight" style="position: absolute; left: 340px; top: 65px; font: bold 13px Arial, sans-serif !important; writing-mode: tb-rl;">margin-right</span><![endif]

Image:offsetHeight.png
The example image above shows a scrollbar and an offsetHeight which fits on the window. However, non-scrollable elements may have large offsetHeight values, much larger than the visible content. These elements are typically contained within scrollable elements; consequently these non-scrollable elements may be completely or partly invisible, depending on the scrollTop setting of the scrollable container.

Specification

Specification Status Comment
CSS Object Model (CSSOM) View Module Working Draft  

Notes

offsetHeight is a property of the DHTML object model which was first introduced by MSIE. It is sometimes referred to as an element's physical/graphical dimensions, or an element's border-box height.

See Also

Attachments

File Size Date Attached by
BirmanCat.jpg
4474 bytes 2005-08-05 20:58:50 GT
offsetHeight.png
14142 bytes 2005-08-07 13:51:41 GT
Boxmodel.gif
8973 bytes 2006-10-26 22:27:47 Majda
understanding_zindex_02.png
5520 bytes 2005-07-09 17:18:16 Lombardp