The DOM scrollHeight property is used to return the height 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.
Syntax:
element.scrollHeight
Return Value: It returns the height of the content of element in pixels.
Example:
<!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> <!-- script to find the scroll height --> <script> function Geeks() { var doc = document.getElementById("content"); var x = doc.scrollHeight; document.getElementById ("p").innerHTML = "Height: " + x + "px"; } </script> </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> </body> </html> |
Output:
Before click on the button:

After click on the button:

Supported Browsers: The browser supported by scrollHeight property are listed below:
- Google Chrome 4.0
- Internet Explorer 8.0
- Firefox 3.0
- Opera
- Safari 4.0
Recommended Posts:
- HTML | DOM lang Property
- HTML | DOM Style backgroundClip Property
- HTML | DOM Style borderTop Property
- HTML | DOM Meter max Property
- HTML | DOM Input Hidden value Property
- HTML | DOM Textarea autofocus Property
- HTML | DOM Style columnGap Property
- HTML | DOM Input Time autofocus Property
- HTML | DOM Input Submit formTarget Property
- HTML | DOM Style boxSizing Property
- HTML | DOM Video seekable Property
- HTML | DOM Input Checkbox disabled Property
- HTML | DOM Source src Property
- HTML | DOM Input Range max Property
- HTML | DOM Video loop Property
- HTML | DOM Button disabled Property
- HTML | DOM Input URL size Property
- HTML | DOM Style borderImageSource Property
- HTML | DOM Style wordBreak Property
- HTML | DOM Base target Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


