Document.scrollingElement is a read-only instance property that returns the Element which scrolls the document. Learn standards vs quirks mode, scroll to top with scrollTop, compare with documentElement and body, and five examples with try-it labs.
01
Kind
Read-only property
02
Returns
Element | null
03
Standard
documentElement
04
Scroll
scrollTop / scrollLeft
05
Quirks
body or null
06
Status
Baseline widely
Fundamentals
Introduction
When users scroll a long page, something in the DOM holds the scroll position. Before scrollingElement, developers often guessed between document.documentElement and document.body. The standard property tells you which element actually scrolls.
MDN: the scrollingElement read-only property returns a reference to the Element that scrolls the document. In standards mode, this is the root element of the document, document.documentElement.
💡
Use it for reliable page scroll
MDN’s example sets scrollTop = 0 on document.scrollingElement to jump to the top. That works across browsers without hard-coding <html> vs <body>.
Document.scrollingElement is marked Baseline Widely available on MDN (since August 2016). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Document.scrollingElement
Read-only Element that scrolls the document — scrollTop, scroll to top, standards vs quirks.
WidelyAvailable
Google ChromeFull support · Desktop & Mobile
Full support
Mozilla FirefoxFull support · Desktop & Mobile
Full support
Apple SafariFull support · macOS & iOS
Full support
Microsoft EdgeFull support · Chromium
Full support
OperaFull support · Modern versions
Full support
Internet ExplorerIE11+ supported
Full support
Document.scrollingElementBaseline support
Bottom line: Use document.scrollingElement for reliable page scroll logic. In standards mode it matches documentElement; pair with window.scrollTo when you prefer the Window API.
Wrap Up
Conclusion
Document.scrollingElement tells you which Element scrolls the page. In standards mode it is the root <html> element. Use scrollTop and scrollLeft for position, or set scrollTop = 0 to jump to the top as MDN demonstrates.
Use document.scrollingElement for page scroll logic
Guard with if (document.scrollingElement) in edge cases
Use <!DOCTYPE html> so standards mode applies
Pair with window.scrollTo when that API is simpler
Read scrollTop for scroll-spy and progress UI
❌ Don’t
Hard-code only document.body for modern pages
Assume scrollingElement is never null
Confuse page scroll with overflow scroll inside a div
Assign to document.scrollingElement (read-only)
Rely on quirks mode behavior in new projects
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about document.scrollingElement
The standard Element that scrolls the document.
5
Core concepts
📄01
Returns
Element|null
API
🌐02
Standard
documentElement
MDN
🔝03
Scroll top
scrollTop=0
MDN
⚠️04
Quirks
body|null
Edge
✅05
Status
Baseline
2016+
❓ Frequently Asked Questions
A read-only reference to the Element that scrolls the document. MDN: in standards mode this is usually document.documentElement (the root <html> element).
No. MDN marks Document.scrollingElement as Baseline Widely available (since August 2016). It is the standard way to find the scrolling root.
MDN example: const scrollElm = document.scrollingElement; scrollElm.scrollTop = 0; You can also use window.scrollTo(0, 0).
In standards mode, yes — MDN says scrollingElement is the root element (documentElement). In quirks mode the behavior differs and may involve body or null.
MDN: in quirks mode scrollingElement returns the HTML body element if it exists and is not potentially scrollable; otherwise null.
Both work for page scroll. scrollingElement gives you the Element with scrollTop/scrollLeft. window.scrollTo is a convenient Window API for the same job.
Did you know?
MDN notes that in quirks mode, scrollingElement may return document.body or even null. That is why modern pages use <!DOCTYPE html> and standards mode, where scrollingElement === document.documentElement.