The HTMLElement.offsetWidth read-only property returns the layout width of an element. Typically, an element's offsetWidth is a measurement which includes the element borders, the element horizontal padding, the element vertical scrollbar (if present, if rendered) and the element CSS width. If the element is hidden (for example, by style.display on the element or one of its ancestors to "none"), then 0 is returned.

Syntax

var offsetWidth =element.offsetWidth;

offsetWidth is a read-only property.

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

 

Example

 

             Image:Dimensions-offset.png

Specification

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'offsetWidth' in that specification.
Working Draft  

Notes

offsetWidth 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 width.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support ? Yes1 Yes ? ?
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes4 ? ? ?

See also