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/2Value
Integer pixel count.
Default
None.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access