English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
scrollWidthA read-only property that returns the entire width of the element (in pixels), including content that is not visible on the screen due to overflow.
The method of measuring width is similar toclientWidthSame: it includes the padding of the element, but not its border, margin, or scrollbar.
It can also include the width of pseudo-elements, such as:: beforeor:: afterIf the content of the element does not require a horizontal scrollbar to fit, then its scrollWidth is equal toclientWidth.
Usage:scrollHeightThe property returns the entire height of the element.
element.scrollWidth
var elem = document.getElementById("box"); var y = elem.scrollHeight; var x = elem.scrollWidth;Test and See‹/›
The numbers in the table specify the first browser version that fully supports the scrollWidth property:
Property | |||||
scrollWidth | 4 | 3 | 10 | 4 | 8 |
Return Value: | A number representing the entire width of the element in pixels |
---|---|
DOM Version: | CSS Object Model (CSSOM) |
HTML DOM Reference:scrollHeight property
HTML DOM Reference:clientWidth property
HTML DOM Reference:offsetWidth property
CSS Reference:overflow property