Element.scrollHeight is a read-only integer: the height of an element’s content, including parts hidden by overflow. It is the minimum height needed to show everything without a vertical scrollbar (MDN).
Read the notes below before you get or set this property. Prefer feature detection when support is limited.
Syntax
Use el.scrollHeight. Start with this line.
JavaScript
element.scrollHeight
Call
What it does
element.scrollHeight
Primary signature.
Built into the browser. Read or assign el.scrollHeight — no import required.
Library declarations
JavaScript
element.scrollHeight
Parameters
Parameter
Description
clientHeight / scrollTop
Optional. Overflow and scroll-position checks
Return Value
Return Value
Description
*
Integer (CSS pixels)
JavaScript Examples
Example 1 — Read scrollHeight
Measure the full content height of a scrollable box.
JavaScript
const box = document.getElementById("box");
// height: 80px; overflow: auto; several lines of content
console.log(box.scrollHeight); // e.g. 180 (full content height)
Visible height.clientHeight is the inner viewport of the box.
Full height.scrollHeight is everything inside, including overflow.
Compare. If scroll is larger than client, content overflows vertically.
Use case. Show a fade, enable “expand”, or decide if a scrollbar is needed.
Example 3 — Scrolled to Bottom
Use a threshold check — scrollTop can be fractional while heights are rounded.
JavaScript
const box = document.getElementById("box");
function atBottom(el) {
return Math.abs(el.scrollHeight - el.clientHeight - el.scrollTop) <= 1;
}
console.log(atBottom(box)); // true when scrolled to the end
Threshold. MDN recommends ≤ 1 because rounding / subpixels differ.
Use case. Unlock an “I agree” checkbox after the user reads to the end.
Compatibility
Browser Support
Element.scrollHeight is Baseline Widely available (MDN: since July 2015). Safe across modern and older evergreen browsers.
✓ Baseline · Widely available
Element.scrollHeight
Read-only content height including overflow — long-standing CSSOM View support.
99%Widely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
scrollHeightExcellent
Bottom line: Safe for production. Prefer a threshold when checking scroll-to-bottom, and compare with clientHeight for overflow detection.
Frequently Asked Questions
A read-only integer: the full height of an element's content in CSS pixels, including content not visible because of overflow. It is the minimum height needed to fit all content without a vertical scrollbar.
No. MDN marks Element.scrollHeight as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
clientHeight is the visible inner height. scrollHeight is the full content height. When content fits without overflow, they are usually equal; when content overflows, scrollHeight is larger.
Yes. Like clientHeight, scrollHeight includes padding but not border, margin, or a horizontal scrollbar (MDN).
Compare the two: if element.scrollHeight > element.clientHeight, the content is overflowing vertically.
Use a small threshold because scrollTop can be fractional: Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) <= 1.