English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML DOM scrollWidth property

HTML DOM Element Object

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.

Syntax:

element.scrollWidth
var elem = document.getElementById("box");
var y = elem.scrollHeight;
var x = elem.scrollWidth;
Test and See‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the scrollWidth property:

Property
scrollWidth431048

Technical Details

Return Value:A number representing the entire width of the element in pixels
DOM Version:CSS Object Model (CSSOM)

Related References

HTML DOM Reference:scrollHeight property

HTML DOM Reference:clientWidth property

HTML DOM Reference:offsetWidth property

CSS Reference:overflow property

HTML DOM Element Object