Name

offsetHeight, offsetWidth — NN n/a IE 4 DOM n/a

Synopsis

Read-only

These properties should represent the height and width of the element’s content, exclusive of padding, borders, or margins. In practice, Internet Explorer 4 for the Macintosh works that way, while the Windows version not only includes padding (if any), but doubles the padding amount in calculating the height and width values. If you don’t use padding in your element, these are accurate measures on both operating systems. Despite these properties being part of the “offset” series, there is no relationship to the containing element for these two properties: an element’s height and width are the same regardless of how they are nested in other containers.

Example

var midpoint = document.all.elementID.offsetWidth/2

Value

Integer pixel count.

Default

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.