Element.scrollHeight is a read-only instance property that measures the full height of an element’s content, including hidden overflow. Learn how it differs from clientHeight, how to detect vertical overflow, how to check whether a user scrolled to the bottom, and how to use it safely—with five examples and try-it labs.
01
Kind
Instance property
02
Access
Read-only
03
Type
Integer (pixels)
04
Includes
Padding & overflow
05
Status
Baseline widely
06
Pairs with
clientHeight, scrollTop
Fundamentals
Introduction
When a box has more content than fits in its visible area, the extra text is hidden behind a scrollbar. scrollHeight tells you how tall the full content is, not just the part you can currently see.
That makes it useful for chat windows, terms-and-conditions boxes, expandable panels, and any UI where you need to know whether content overflows or whether the user reached the end.
Think of scrollHeight as “how tall would this box need to be to show all content without scrolling vertically?”
Concept
Understanding the Property
MDN: the read-only scrollHeight property is a measurement of the height of an element’s content, including content not visible on the screen due to overflow.
Read-only — use it to measure, not assign.
Includes padding — measured like clientHeight.
Excludes border and margin — and horizontal scrollbars.
Equals clientHeight when content fits — no vertical overflow needed.
Foundation
📝 Syntax
JavaScript
scrollHeight
Value
An integer representing the total content height in CSS pixels.
Item
Detail
Type
Integer (pixels)
Access
Read-only property
Includes
Padding and hidden overflow content
Excludes
Border, margin, horizontal scrollbar
Related
clientHeight, offsetHeight, scrollTop
⚠️
Rounded values
scrollHeight and clientHeight are rounded, while scrollTop can contain decimals. Use a small threshold when checking whether the user reached the bottom.
Pattern
📋 MDN Scroll-to-Bottom Check
MDN recommends this threshold pattern because exact equality can fail when scrollTop contains decimals:
Element.scrollHeight is Baseline Widely available (MDN: across browsers since July 2015). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Element.scrollHeight
Read-only — returns the full content height in pixels, including hidden overflow.
BaselineWidely available
Google ChromeSupported
Yes
Microsoft EdgeSupported
Yes
Mozilla FirefoxSupported
Yes
Apple SafariSupported
Yes
OperaSupported
Yes
Internet ExplorerSupported
Yes
scrollHeightBaseline
Bottom line: Use scrollHeight to measure full content height, detect overflow, and build reliable scroll-to-bottom checks with clientHeight and scrollTop.
Wrap Up
Conclusion
scrollHeight is the full-content height measurement behind many scroll-based UI patterns. It includes hidden overflow, works with clientHeight, and pairs naturally with scrollTop for bottom detection.
Compare scrollHeight with clientHeight for overflow checks
Use a threshold when testing for bottom-of-scroll
Re-measure after content or styles change
Pair with scrollTop for progress and read-state logic
Test on real scrollable containers, not only the page body
❌ Don’t
Assume exact equality with scrollTop will always work
Confuse scrollHeight with offsetHeight
Forget that border and margin are excluded
Assign el.scrollHeight = ... (read-only)
Measure once and expect the value to stay fixed forever
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about scrollHeight
Read-only integer height for all content, including hidden overflow.
5
Core concepts
📄01
Get only
on Element
Kind
📝02
integer
pixels
Type
🔍03
Full content
includes overflow
Use
✅04
Baseline
widely available
Status
🎯05
Use threshold
for bottom checks
Tip
❓ Frequently Asked Questions
It returns the total height of an element's content, including content that is not visible because of overflow. It is a read-only measurement in pixels.
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 of the element. scrollHeight is the full content height needed to show everything without a vertical scrollbar. When content fits, they are usually equal.
Yes. Like clientHeight, scrollHeight includes padding but not border, margin, or a horizontal scrollbar.
Compare scrollHeight and clientHeight. If scrollHeight is greater than clientHeight, the content is overflowing vertically.
Use a threshold check because scrollTop can contain decimals: Math.abs(element.scrollHeight - element.clientHeight - element.scrollTop) <= 1.
Did you know?
MDN’s “read the text before agreeing” demo works because scrollHeight, clientHeight, and scrollTop together tell you whether the user reached the bottom of a scrollable box.