Back to Content

Document: scrollingElement property

files/en-us/web/api/document/scrollingelement/index.md

latest892 B
Original Source

{{APIRef("DOM")}}

The scrollingElement read-only property of the {{domxref("Document")}} interface returns a reference to the {{domxref("Element")}} that scrolls the document. In standards mode, this is the root element of the document, {{domxref("document.documentElement")}}.

When in quirks mode, the scrollingElement attribute returns the HTML body element if it exists and is not potentially scrollable, otherwise it returns null. This may look surprising but is true according to both the specification and browsers.

Value

The {{domxref("Element")}} that scrolls the document, usually the root element (unless not in standard mode).

Examples

js
const scrollElm = document.scrollingElement;
scrollElm.scrollTop = 0;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}