Skip to content
Related Articles

Related Articles

HTML | DOM scrollWidth Property

View Discussion
Improve Article
Save Article
  • Last Updated : 10 Aug, 2022

The DOM scrollWidth property is used to return the width of an element. This property includes padding and also the content that is not visible on the screen due to overflow but not include border, scrollbar or margin. It is a read-only property. 



Return Value: It returns the width of the content of element in pixels. 



<!DOCTYPE html>
        HTML DOM scrollWidth Property
        #box {
            width: 250px;
            overflow: auto;
        #content {
            width: 500px;
            padding: 10px;
            background-color: green;
            color: white;
    <!-- script to find width of scroll -->
        function Geeks() {
            var doc = document.getElementById("content");
            var x = doc.scrollWidth;
                = "Width: " + x + "px";
        DOM scrollWidth Property
    <button onclick="Geeks()">
        Click Here!
    <div id="box">
        <div id="content">
            Text content...
    <p id="p"></p>


Before click on the button:


After click on the button:


Supported Browsers: The browser supported by DOM scrollWidth property are listed below:

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 5
  • Firefox 1
  • Opera 12.1
  • Safari 1

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!