MDN wants to learn about developers like you:

Traduzione in corso.

La proprietà a sola lettura HTMLElement.offsetWidth restituisce la larghezza del layout di un elemento. In genere, l'offsetWidth di un elemento è la misura che include i bordi degli elementi, l'elemento di riempimento orizzontale, l'elemento scrollbar verticale (se presente) e l'elemento CSS "width".


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().






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


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

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) ? ? ? ?
Feature Android Android Webview Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? (Yes) (Yes) ? ? ? ? ? (Yes)

In compliance with the specification, this property will return null on Webkit if the element is hidden (the style.display of this element or any ancestor is "none") or if the style.position of the element itself is set to "fixed".

This property will return null on Internet Explorer (9) if the style.position of the element itself is set to "fixed". (Having display:none does not affect this browser.)

See also


Tag del documento e collaboratori

 Hanno collaborato alla realizzazione di questa pagina: kerby58
 Ultima modifica di: kerby58,