scrollIntoView()
The scrollIntoView() method of the Element interface scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | 79 | 1 | 3 | 18 | 1 | |
scrollIntoView (options parameter) `options` parameter | 61 | 79 | 36 | 14 | 61 | 14 |
scrollIntoView (options parameter block option) `block` option | 61 | 79 | 58 | 14 | 61 | 14 |
scrollIntoView (options parameter inline option) `inline` option | 61 | 79 | 58 | 14 | 61 | 14 |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Notes 6 item(s)
Limitation
- This browser only partially implements this feature
Removed
- This feature was removed in a later browser version (79)
- This feature was removed in a later browser version (17)
Implementation note
- The only parameter supported is `alignToTop`.
- Only supported for `HTMLElement`, not all `Element` objects, such as `SVGElement`.
- No support for `smooth` behavior.
Notes 2 item(s)
Implementation note
- No support for `center` option.
- Before Safari 15.4, there was no support for the `smooth` behavior.
Notes 2 item(s)
Implementation note
- No support for `center` option.
- Before iOS 15.4, there was no support for the `smooth` behavior.
Notes 3 item(s)
Limitation
- This browser only partially implements this feature
Removed
- This feature was removed in a later browser version (58)
Implementation note
- Only values `"top"` and `"bottom"`, not `"nearest"` and `"center"`.
Syntax
JAVASCRIPT
scrollIntoView()
scrollIntoView(alignToTop)
scrollIntoView(options) Use cases
-
Using scrollIntoView()
The scrollIntoView() method of the Element interface scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user.
Cautions
- May not be supported in older browsers.
Implementation notes
- Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.