Our volunteers haven't translated this article into Română yet. Join us and help get the job done!
You can also read the article in English (US).

The scrollTo() method of the Element interface scrolls to a particular set of coordinates inside a given element.

Syntax

element.scrollTo(x-coord, y-coord)
element.scrollTo(options)

Parameters

  • x-coord is the pixel along the horizontal axis of the element that you want displayed in the upper left.
  • y-coord is the pixel along the vertical axis of the element that you want displayed in the upper left.

- or -

Examples

element.scrollTo(0, 1000);

Using options:

element.scrollTo({
  top: 100,
  left: 100,
  behavior: 'smooth'
});

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'element.scrollTo()' in that specification.
Working Draft Initial definition.

Browser Compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
scrollToChrome Full support 45Edge No support NoFirefox Full support YesIE No support NoOpera Full support 32Safari Full support 10WebView Android Full support 45Chrome Android Full support 45Firefox Android Full support YesOpera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support Yes
ScrollToOptions parameterChrome Full support 45Edge No support NoFirefox Full support YesIE No support NoOpera Full support 32Safari No support NoWebView Android Full support 45Chrome Android Full support 45Firefox Android Full support YesOpera Android Full support 32Safari iOS No support NoSamsung Internet Android Full support Yes

Legend

Full support  
Full support
No support  
No support

See also

Document Tags and Contributors

Contributors to this page: myf, mdnwebdocs-bot, mfluehr, chrisdavidmills
Last updated by: myf,