Element.scrollIntoView() scrolls the element’s ancestor containers so that element becomes visible to the user (MDN). Call it on the target you want to see — not on the scroller. Contrast with scroll(), which needs pixel coordinates.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call el.scrollIntoView. Start with this line.
JavaScript
el.scrollIntoView() / boolean / options Who scrolls? Ancestor containers — not “pixels on el” Default block: "start", inline: "nearest"
Call
What it does
el.scrollIntoView() / boolean / options Who scrolls? Ancestor containers — not “pixels on el” Default block: "start", inline: "nearest"
Primary signature.
el.scrollIntoView(...)
Call with the arguments your case needs.
Built into the browser. Call scrollIntoView(...) on an Element — no import required.
Library declarations
JavaScript
el.scrollIntoView() / boolean / options Who scrolls? Ancestor containers — not “pixels on el” Default block: "start", inline: "nearest"
Await finish. Useful before focusing or highlighting the target.
interrupted. True if another programmatic scroll cut this short.
Feature-detect. Check whether the return value is a Promise.
Fallback. Scroll still works without Promise support.
Compatibility
Browser Support
Element.scrollIntoView() is Baseline Widely available (MDN, since January 2020). It is not Deprecated, Experimental, or Non-standard. Promise return / interrupted may vary — feature-detect if you depend on it.
✓ Baseline Widely available
Element.scrollIntoView()
Scroll ancestors until this element is visible. Prefer options for smooth + block/inline alignment.
BaselineWidely available
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
scrollIntoView()Baseline
Bottom line: Safe for modern apps. Use options for alignment; add scroll-margin when a fixed header overlaps the target.
Frequently Asked Questions
It scrolls the element’s ancestor containers so that element becomes visible to the user (MDN). You can pass a boolean or an options object with behavior, block, and inline.
No. MDN marks Element.scrollIntoView() as Baseline Widely available (since January 2020). It is not Deprecated, Experimental, or Non-standard. Some parts (such as the Promise return) may vary by browser.
MDN documents a Promise that fulfills with { interrupted }. interrupted is true if another programmatic scroll started before this one finished. Feature-detect if you rely on the Promise.
scrollIntoView() scrolls ancestors until this element is visible — you pick the target element, not pixel coordinates. scroll() / scrollTo() jump to absolute offsets inside one scrollable element.
block is vertical alignment: start, center, end, nearest (default start). inline is horizontal: start, center, end, nearest (default nearest) (MDN).
Use CSS scroll-margin-top (or scroll-margin-bottom) on the target so scrollIntoView() leaves space for sticky/fixed navbars (MDN).