JavaScript Element scroll() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Method

Definition

Element.scroll() scrolls to a particular set of coordinates inside that element (MDN). Pass (x, y) or an options object with top, left, and behavior. It is an alias of scrollTo().

Pass the required arguments shown below. Check return values and browser support before you rely on the result.

Syntax

Call el.scroll. Start with this line.

JavaScript
el.scroll(x, y) or el.scroll(options)
CallWhat it does
el.scroll(x, y) or el.scroll(options)Primary signature.
el.scroll(...)Call with the arguments your case needs.

Built into the browser. Call scroll(...) on an Element — no import required.

Library declarations
JavaScript
el.scroll(x, y) or el.scroll(options)

Parameters

ParameterDescription
options.behaviorOptional. smooth, instant, or auto
Promise interruptedOptional. True if another scroll cut this one short

Return Value

Return ValueDescription
*Promise<{ interrupted }> (support varies)

JavaScript Examples

Example 1 — Scroll to Coordinates

MDN: put the 1000th vertical pixel at the top of the element.

JavaScript
const box = document.getElementById("box");

box.scroll(0, 1000);
console.log("scrollTop:", box.scrollTop);
Try It Yourself

How It Works

  1. Absolute target. scroll(0, 1000) means left 0, top 1000.
  2. Not a delta. Calling it again stays at the same place.
  3. Confirm. Read scrollTop after the call.
  4. Clamp. If max scroll is smaller, the browser clamps the value.

Example 2 — Smooth Options Object

MDN options form with behavior: "smooth".

JavaScript
const box = document.getElementById("box");

box.scroll({
  top: 100,
  left: 100,
  behavior: "smooth",
});
Try It Yourself

How It Works

  1. Object form. Same absolute scroll, clearer for options.
  2. smooth. Animates over time instead of jumping.
  3. auto. Default — follows CSS scroll-behavior.
  4. instant. Jump in one step (MDN).

Example 3 — Await the Promise

MDN: respond when a smooth scroll finishes; check interrupted.

JavaScript
const box = document.getElementById("box");

async function go() {
  const result = await box.scroll({
    top: 1000,
    behavior: "smooth",
  });
  console.log("interrupted?", result.interrupted);
}

go();
Try It Yourself

How It Works

  1. Await finish. Useful for smooth scrolls that take time.
  2. interrupted. True if another programmatic scroll started first.
  3. Feature-detect. MDN: test box.scroll(0, 0) instanceof Promise.
  4. Fallback. If no Promise, scroll still works — just no await.

Browser Support

Element.scroll() 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.scroll()

Scroll an element to absolute coordinates or options. Alias of scrollTo(); pair with scrollBy for relative moves.

Baseline Widely available
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Android WebView Supported · Modern WebView
Full support
scroll() Baseline

Bottom line: Safe for modern apps. Prefer options + behavior for smooth UX; detect Promise support before awaiting.

Frequently Asked Questions

It scrolls an element to a particular set of coordinates inside that element (MDN). Pass x/y numbers or an options object with top, left, and behavior.
No. MDN marks Element.scroll() 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 on the same element before the first finished. Feature-detect if you rely on the Promise.
Yes. MDN treats Element.scroll() as an alias of Element.scrollTo() — same syntax and behavior.
scroll() / scrollTo() move to absolute coordinates. scrollBy() moves by a relative delta from the current position.
Optional string: smooth (animate), instant (jump), or auto (use the element’s CSS scroll-behavior). Default is auto (MDN).

Next: Element scrollTo()

Same method under the scrollTo name — deepen the absolute-scroll pattern.

scrollTo() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful