The Wayback Machine - https://web.archive.org/web/20240623085908/https://www.geeksforgeeks.org/html-dom-scrollheight-property/
Open In App

HTML DOM scrollHeight Property

Last Updated : 30 Jun, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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

Syntax:

element.scrollHeight

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

Example: In this example, we will use DOM scrollHeight property.

HTML




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML DOM scrollHeight Property
    </title>
    <style>
        #GFG {
            width: 250px;
            height: 100px;
            overflow: auto;
            margin: auto;
        }
        #content {
            height: 300px;
            padding: 10px;
            background-color: green;
            color: white;
        }
    </style>
</head>
 
<body style="text-align: center;">
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>
        DOM scrollHeight Property
    </h2>
    <button onclick="Geeks()">
        Click me!
    </button>
    <br><br>
    <div id="GFG">
        <div id="content">
            Text content...
        </div>
    </div>
    <p id="p"></p>
   
      <!-- script to find the scroll height -->
    <script>
        function Geeks() {
            let doc = document.getElementById("content");
            let x = doc.scrollHeight;
            document.getElementById("p").innerHTML
                = "Height: " + x + "px";
        }
    </script>
 
</body>
 
</html>


Output: 

Supported Browsers: The browser supported by the scrollHeight property are listed below:

  • Google Chrome 1.0
  • Edge 12.0
  • Internet Explorer 5.0
  • Firefox 21.0
  • Opera 8.0
  • Safari 1.0


Previous Article
Next Article

Similar Reads

jQWidgets jqxScheduler scrollHeight() Method
jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful, optimized, platform-independent, and widely supported framework. The jqxScheduler widget is used to show a set of appointments in a day, week, month, timeline day, timeline week as well as timeline month views. The scrollHeight()
2 min read
HTML DOM lang Property
In HTML document, the lang property is used to set or return the value of the lang attribute of an element. This attribute specifies the language code of the element's content. The element attribute takes "en" for English, "ja" for Japanese, "es" for Spanish, and so on. The default value of this attribute is unknown. Syntax: Get the value of lang:
2 min read
HTML DOM Style backgroundClip Property
The DOM style backgroundClip Property is used to set or return the painting area of the background. Syntax: It is used to return the backgroundClip property.object.style.backgroundClip It is used to set the backgroundClip property. object.style.backgroundClip = "border-box|padding-box|content-box|initial|inherit" Property Values: border-box propert
1 min read
HTML DOM Style borderTop Property
The DOM style borderTop property is used to set or return the three different border-top property such as border-top-width, border-top-style, and border-top-color of an element. Syntax: It returns the borderTop property. object.style.borderTopIt is used to set the borderTop property. object.style.borderTop = "width style color|initial|inherit" Prop
2 min read
HTML | DOM Meter max Property
The DOM Meter max Property is used to set or return the value of the max attribute of a gauge. The max attribute is used to specify the upper bound of the gauge and the value of the max attribute must be greater than the value of the min attribute. It has a default value which is 1. Syntax: It return the max property.meterObject.maxIt is used to se
2 min read
HTML | DOM Input Hidden value Property
The Input Hidden value property in HTML DOM is used to set or return the value of the value attribute of the hidden input field. The value attribute defines the default value of the input hidden field. Syntax: It returns the value property.hiddenObject.valueIt is used to set the value property.hiddenObject.value = text Property Values: This propert
2 min read
HTML DOM Marquee direction Property
The marquee direction property in HTML DOM is used to set or return the value of the direction attribute of the &lt;marquee&gt; tag. Syntax: It is used to return the marquee direction property. marqueeObject.direction; It is used to set the marquee direction property. marqueeObject.direction = "up|down|left|right" Note: This property is depreciated
2 min read
HTML | DOM Textarea autofocus Property
The DOM Textarea autofocus Property is used to set or return whether the element should get focus when the page loads. This property is used to reflect the HTML autofocus attribute. Syntax: It is used to Return the autofocus property. textareaObject.autofocusIt is used to Set the autofocus property. textareaObject.autofocus = true|false Property Va
2 min read
HTML | DOM Style columnGap Property
The DOM Style columnGap property specifies the gap between the columns. Syntax : For return the value: object.style.columnGap For set the value: object.style.columnGap = "length|normal|initial|inherit" Property Values: length: Set the column gap in length unit. normal: The default value of column gap. initial: Sets the default value. inherit: Inher
4 min read
HTML | DOM Input Time autofocus Property
The DOM Input Time autofocus Property in HTML DOM is used to set or return whether the time field should automatically get focus or not when the page loads. This Property is used to reflect the HTML autofocus attribute. Syntax: It returns an autofocus Property. timeObject.autofocus It is used to set the autofocus property. timeObject.autofocus = tr
2 min read
Article Tags :
three90RightbarBannerImg