MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    Element.scrollWidth

    The Element.scrollWidth read–only property returns either the width in pixels of the content of an element or the width of the element itself, whichever is greater. If the element is wider than its content area (for example, if there are scroll bars for scrolling through the content), the scrollWidth is larger than the clientWidth.

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

    Syntax

    var xScrollWidth = element.scrollWidth;

    xScrollWidth is the width of the content of element in pixels.

    Example

    <div id="aDiv"
         style="width: 100px; height: 200px; overflow: auto;"
    >-FooBar-FooBar-FooBar</div>
    <br>
    <input type="button" value="Show scrollWidth"
           onclick="alert(document.getElementById('aDiv').scrollWidth);">

    Specification

    The CSSOM View Module defines scrollWidth

    References

    MSDN: scrollWidth Property

    See also

    Document Tags and Contributors

    Last updated by: fscholz,
    Hide Sidebar