coderef

Scroll methods on elementsBaseline · Widely available

The scroll() and scrollBy() methods change the scroll position of overflow content within an element. Similar to setting scrollTop and scrollLeft properties, but with options setting whether the scroll should animate smoothly or jump. Note that scrollTo() is an alias for scroll().

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Sep 16, 2020. Widely available since Mar 16, 2023.

Browser support

DesktopChrome
1–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–35Not supported
36+Supportedsince Feb 24, 2015
Current: 157
Safari
1–13.1Not supported
14+Supportedsince Sep 16, 2020
Current: 27
MobileChrome Android
18–60Not supported
61+Supportedsince Sep 5, 2017
Current: 155
Firefox Android
4–35Not supported
36+Supportedsince Feb 27, 2015
Current: 157
Safari iOS
1–13.4Not supported
14+Supportedsince Sep 16, 2020
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: scroll event.

Feature detection

JS · check before using
if ("Document" in globalThis && "scrollingElement" in Document.prototype) {
  // Document.scrollingElement is available
}

Sub-features

Support for each part of the feature (35). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Document.scroll_event112621861
Document.scrollingElement441248944489
Element.scroll61793610.1613610.3
Element.scroll.options_behavior_parameter61793614613614
Element.scroll.options_left_parameter61793610.1613610.3
Element.scroll.options_top_parameter61793610.1613610.3
Element.scrollBy61793610.1613610.3
Element.scrollBy.options_behavior_parameter61793614613614
Element.scrollBy.options_left_parameter61793610.1613610.3
Element.scrollBy.options_top_parameter61793610.1613610.3
Element.scrollHeight11221118211
Element.scrollLeft112111841
Element.scrollTo61793610.1613610.3
Element.scrollTo.options_behavior_parameter61793614613614
Element.scrollTo.options_left_parameter61793610.1613610.3
Element.scrollTo.options_top_parameter61793610.1613610.3
Element.scrollTop112111841
Element.scrollWidth112111841
Element.scroll_event11261.31861
Window.scroll112111841
Show 15 more
Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
Window.scroll.options_behavior_parameter61793614613614
Window.scroll.options_left_parameter41793610.1413610.3
Window.scroll.options_top_parameter41793610.1413610.3
Window.scrollBy112111841
Window.scrollBy.options_behavior_parameter61793614613614
Window.scrollBy.options_left_parameter41793610.1413610.3
Window.scrollBy.options_top_parameter41793610.1413610.3
Window.scrollTo112111841
Window.scrollTo.options_behavior_parameter61793614613614
Window.scrollTo.options_left_parameter41793610.1413610.3
Window.scrollTo.options_top_parameter41793610.1413610.3
Window.scrollX112111841
Window.scrollX.subpixel_precision40≤1855✕4055✕
Window.scrollY112111841
Window.scrollY.subpixel_precision40≤1855✕4055✕