The Element interface's scrollIntoView() method scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user. 
 The Element interface's scrollIntoView() method scrolls the element's ancestor containers such that the element on which scrollIntoView() is called is visible to the user. 
js
scrollIntoView() scrollIntoView(alignToTop) scrollIntoView(scrollIntoViewOptions)
alignToTop Optional
A boolean value:
true, the top of the element will be aligned to the top of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "start", inline: "nearest"}. This is the default value. false, the bottom of the element will be aligned to the bottom of the visible area of the scrollable ancestor. Corresponds to scrollIntoViewOptions: {block: "end", inline: "nearest"}. scrollIntoViewOptions Optional  Experimental  An Object with the following properties:
behavior Optional
Determines whether scrolling is instant or animates smoothly. This option is a string which must take one of the following values:
smooth: scrolling should animate smoothlyinstant: scrolling should happen instantly in a single jumpauto: scroll behavior is determined by the computed value of scroll-behavior
block Optional
 Defines vertical alignment. One of start, center, end, or nearest. Defaults to start. 
inline Optional
 Defines horizontal alignment. One of start, center, end, or nearest. Defaults to nearest. 
None (undefined).
js
const element = document.getElementById("box"); element.scrollIntoView(); element.scrollIntoView(false); element.scrollIntoView({ block: "end" }); element.scrollIntoView({ behavior: "smooth", block: "end", inline: "nearest" });
The element may not be scrolled completely to the top or bottom depending on the layout of other elements.
| Specification | 
|---|
| CSSOM View Module # dom-element-scrollintoview | 
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
| scrollIntoView | 1 | 79 17–79The only parameter supported isalignToTop.12–17["Only supported forHTMLElement, not allElementobjects, such asSVGElement.", "No support forsmoothbehavior."] | 1 | 5["Only supported forHTMLElement, not allElementobjects, such asSVGElement.", "No support forsmoothbehavior orcenteroptions."] | ≤12.1 | 3["No support forcenteroption.", "Before Safari 15.4, there was no support for thesmoothbehavior."] | 4.4 | 18 | 4 | ≤12.1 | 1["No support forcenteroption.", "Before iOS 15.4, there was no support for thesmoothbehavior."] | 1.0 | 
| options_parameter | 61Theblockandinlineoptions support the valuesstart,center,end,nearest. | 79Theblockandinlineoptions support the valuesstart,center,end,nearest. | 36["No support forinlineoption.", "Before Firefox 58,nearestandcentervalues for theblockoption was unsupported. See bug 1389274."] | No | 48Theblockandinlineoptions support the valuesstart,center,end,nearest. | 14 | 61Theblockandinlineoptions support the valuesstart,center,end,nearest. | 61Theblockandinlineoptions support the valuesstart,center,end,nearest. | 36["No support forinlineoption.", "Before Firefox 58,nearestandcentervalues for theblockoption was unsupported. See bug 1389274."] | 45Theblockandinlineoptions support the valuesstart,center,end,nearest. | 14 | 8.0Theblockandinlineoptions support the valuesstart,center,end,nearest. | 
Element.scrollIntoViewIfNeeded()  Non-standard 
    © 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
    https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView