Testing

scrollIntoView: Browser Support, Options, Issues

scrollIntoView is a W3C JavaScript method that scrolls an element into view. Learn which browsers support it, the options it accepts, and the known issues.

Author

Prince Dewani

May 2, 2026

scrollIntoView is a JavaScript method on the Element interface, defined by the W3C CSSOM View Module, that scrolls an element into the visible viewport. It works in Chrome 61+, Edge 79+, Firefox 36+, Safari 16+ on macOS and iOS, Opera 48+, and Samsung Internet 8.2+, while Internet Explorer never added full support.

This guide covers what scrollIntoView is, the browsers that support it, the options object, how to use it in JavaScript, and the known issues that cause failures.

What is scrollIntoView?

scrollIntoView is an Element method standardized in the W3C CSSOM View Module. Calling element.scrollIntoView() asks the browser to scroll every scrollable ancestor until the target appears in the viewport, with optional control over alignment and animation through an options object.

Which browsers does scrollIntoView support?

scrollIntoView works in every major modern browser, including Chrome, Edge, Firefox, Safari, Opera, and Samsung Internet. Internet Explorer shipped only the Boolean form and never added the smooth behavior or the options dictionary.

Loading browser compatibility data...

scrollIntoView compatibility in Chrome

Chrome supports scrollIntoView from Chrome 61 on desktop and Android, with the smooth behavior shipping at the same release. Chrome 4 to 60 had partial support that handled the Boolean argument but not the options dictionary, and the smooth animation only became reliable after Chrome 61.

scrollIntoView compatibility in Edge

Edge supports scrollIntoView from Edge 79 on desktop, the first Chromium-based release that brought the smooth behavior. Legacy Edge 12 to 18 had partial support that included the Boolean form and parts of the options dictionary, but missed the smooth animation.

scrollIntoView compatibility in Firefox

Firefox supports scrollIntoView from Firefox 36 on desktop and Firefox for Android, including the options dictionary and the smooth behavior in the same release. Firefox 2 to 35 had partial support that recognized only the Boolean argument and ignored the options object.

scrollIntoView compatibility in Safari

Safari supports scrollIntoView from Safari 16 on macOS and iOS, with the options dictionary first shipping in Safari 15.4. Safari 5.1 to 15.6 had partial support that handled the Boolean form but ignored the smooth behavior, and Safari 3.1 to 5 on macOS did not support the method at all.

scrollIntoView compatibility in Opera

Opera supports scrollIntoView from Opera 48 on desktop and Opera Mobile 80 on Android, with the smooth behavior arriving at the same release. Opera 11.6 to 47 had partial support, and Opera Mini does not support scrollIntoView in any version because it strips client-side scrolling on the server.

scrollIntoView compatibility in Samsung Internet

Samsung Internet supports scrollIntoView from Samsung Internet 8.2 on Android, with the smooth behavior arriving in version 8.0. Samsung Internet 4 to 7.4 had partial support that handled the Boolean argument, and Samsung Internet 2 and 3 did not include the method.

scrollIntoView compatibility in Android Browser

The WebView-based Android Browser supports scrollIntoView from version 147 on, matching its underlying Chromium release. Android Browser 2.3 to 4.4.4 shipped partial support that handled the Boolean form, and Android Browser 4.0 and earlier had no smooth behavior.

scrollIntoView compatibility in Internet Explorer

Internet Explorer 8 to 11 ship only the Boolean form of scrollIntoView. The options dictionary and the smooth behavior never landed in IE, and Internet Explorer 5.5 to 7 did not support the method at all. Microsoft has retired Internet Explorer, so apps still on IE need the smoothscroll polyfill or a migration to Edge.

Note

Note: scrollIntoView behavior shifts between Safari, Chrome, and Firefox, especially around the smooth animation and fixed-header offsets. Test it on real browsers and OS with TestMu AI. Try TestMu AI free!

What are the scrollIntoView options?

scrollIntoView accepts either a Boolean argument (legacy form) or an options object with three properties: behavior, block, and inline. The options object gives you precise control over alignment and animation, and every Chromium-based browser, Firefox 36+, and Safari 15.4+ honor it.

  • behavior: Controls whether the scroll animates or jumps. Accepts auto (the browser picks based on the target's CSS scroll-behavior), smooth (animated), or instant (one-frame jump). Defaults to auto.
  • block: Sets vertical alignment inside the scroll container. Accepts start (default), center, end, or nearest. The nearest value picks the closest edge to minimize the scroll distance.
  • inline: Sets horizontal alignment. Accepts start, center, end, or nearest (default). Most pages do not need to scroll horizontally, so nearest leaves the X axis untouched.
  • Boolean legacy form: scrollIntoView(true) aligns the element's top edge with the top of the scroll container, and scrollIntoView(false) aligns the bottom edge with the bottom. The Boolean form predates the options object and ignores behavior.
  • No arguments: Calling scrollIntoView() with no arguments behaves like scrollIntoView(true), aligning the element to the top of its scrollable ancestor with the browser's default scroll behavior.

How do you use scrollIntoView in JavaScript?

Get a reference to the target element, call scrollIntoView on it, and pass an options object that describes the alignment and animation you want. The browser walks every scrollable ancestor and scrolls each one until the target reaches the configured position.

  • Pick a target element: Use document.querySelector or any DOM lookup that returns the element you want to bring into view.
  • Feature-detect the method: Confirm typeof element.scrollIntoView === "function" before calling it, so the code degrades cleanly on browsers that ship an empty stub or no implementation.
  • Pass the options object: Set behavior (smooth or instant), block (vertical alignment), and inline (horizontal alignment) to match the design.
  • Call scrollIntoView: The browser scrolls every scrollable ancestor until the target reaches the configured alignment.
  • Handle scroll completion: Listen for the scrollend event on the scroll container if you need to run code once the smooth animation finishes.
// Smoothly scroll a section into the center of the viewport.
const target = document.querySelector("#section-pricing");

if (target && typeof target.scrollIntoView === "function") {
  target.scrollIntoView({
    behavior: "smooth", // animate the scroll instead of jumping
    block: "center",    // align vertically in the middle of the viewport
    inline: "nearest",  // leave the horizontal axis alone unless needed
  });
} else {
  console.warn("scrollIntoView is not supported in this browser.");
}

If the page does not move, log the target first; scrollIntoView quietly returns when the target is null, detached from the DOM, or hidden with display: none.

...

Why is scrollIntoView not working?

scrollIntoView covers most cases, but a handful of edge cases catch teams off guard, especially around iOS Safari, fixed headers, and nested scroll containers.

  • iOS Safari ignores smooth before 16: Safari on iOS 5 to 15.8 jumps directly to the target even when behavior: "smooth" is set. The smooth animation only fires reliably from Safari 16 on iOS, so older iPhones either jump or stall mid-scroll.
  • Fixed headers cover the target: scrollIntoView does not subtract a header offset, so the element lands underneath a sticky header. Add scroll-margin-top: 80px (or your header height) on the target to push the final position below the header without writing custom math.
  • Detached or hidden elements silently fail: The method returns undefined when the target is null, removed from the DOM, or hidden with display: none. Run console.log on the target before calling scrollIntoView to confirm the node is present.
  • Nested scroll containers scroll the wrong axis: When several ancestors can scroll, the browser scrolls each one in turn. Pass inline: "nearest" to keep the horizontal axis still and limit motion to the vertical scroll, especially inside drag-and-drop kanban boards.
  • In my experience, late DOM mounts break the call: React, Vue, and Angular often render the target inside an effect that runs after the initial scroll attempt, so the call hits a stale ref. Wrap scrollIntoView in requestAnimationFrame or a useEffect with the target ref so the browser waits for layout before scrolling.
  • JSDOM does not implement the method: Jest tests that render with JSDOM throw scrollIntoView is not a function because the test runtime ships an empty stub. Mock Element.prototype.scrollIntoView with jest.fn() in your setup file to silence the error.
...

Citations

All scrollIntoView version numbers and platform notes in this guide come from these primary sources:

Author

Prince Dewani is a Community Contributor at TestMu AI, where he manages content strategies around software testing, QA, and test automation. He is certified in Selenium, Cypress, Playwright, Appium, Automation Testing, and KaneAI. Prince has also presented academic research at the international conference PBCON-01. He further specializes in on-page SEO, bridging marketing with core testing technologies. On LinkedIn, he is followed by 4,300+ QA engineers, developers, DevOps experts, tech leaders, and AI-focused practitioners in the global testing community.

Open in ChatGPT Icon

Open in ChatGPT

Open in Claude Icon

Open in Claude

Open in Perplexity Icon

Open in Perplexity

Open in Grok Icon

Open in Grok

Open in Gemini AI Icon

Open in Gemini AI

Copied to Clipboard!
...

3000+ Browsers. One Platform.

See exactly how your site performs everywhere.

Try it free
...

Write Tests in Plain English with KaneAI

Create, debug, and evolve tests using natural language.

Try for free

Frequently asked questions

Did you find this page helpful?

More Related Hubs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests