CSS overflow-anchor Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The overflow-anchor property controls scroll anchoring. When content above the visible area grows or shrinks, the browser can adjust the scroll offset so the text you were reading stays put instead of jumping.

The initial value is auto, and anchoring is on by default where supported. You usually set this property only to opt out with none on a document, a scroll container, or a specific element that should not be chosen as an anchor. It is not the same as overflow, which controls clipping and scrollbars.

Baseline · Newly available.

Not deprecated and not experimental. Standard-track CSS Scroll Anchoring. Widely supported in Chromium and Firefox; Safari support starts at Safari 27. Use a progressive approach if older Safari must keep reading without jumps.

CSS Syntax

syntax.css
overflow-anchor: auto | none | initial | inherit;

Property Values

ValueDescriptionTry it
autoDefault. The element may be used as a scroll anchorTry it
noneThe element is excluded from scroll anchoringTry it
initialResets to the initial value, autoTry it
inheritTakes the value from the parent elementTry it

How to Use overflow-anchor

Leave the default alone unless anchoring causes a problem, then opt out where needed.

  1. Build a scrollable area with overflow set to auto or scroll, or use the page scroll.
  2. Keep overflow-anchor: auto (the default) so the browser can stabilize scroll when content above changes.
  3. If a jump still feels wrong, set overflow-anchor: none on the changing element, the scroll container, or (rarely) the whole document.
  4. Test with real inserts: ads, lazy images, comments, and chat messages above the fold.
PieceRequired?Role
Scrollable contextYesPage scroll or a box with overflow that can scroll
Content change aboveTo observeInserts or resizes above the visible lines trigger anchoring
autoDefaultAllow the element to be an anchor
noneOpt-out onlyExclude the element from anchoring

Live Preview

Scroll halfway down, then insert a block above. With auto, supported browsers try to keep your reading spot. With none, the view can jump.

Scroll to Line 6 first, then click Insert above. Compare auto and none in a supporting browser.

Scroll box

Line 1 — scroll past me

Line 2

Line 3

Line 4

Line 5

Line 6 — keep this in view

Line 7

Line 8

Line 9

Line 10

overflow-anchor: auto

CSS Examples

Each snippet focuses on overflow-anchor. Use Try It Yourself for a live editor with a small insert button.

Example 1 — Keep the Default

Leave anchoring on so the browser can stabilize scroll when content is inserted above.

CSS
<style>
  .feed {
    height: 120px;
    overflow: auto;
    overflow-anchor: auto;
    border: 1px solid #cbd5e1;
  }
</style>

<div class="feed">
  <p>Older item</p>
  <p>Reading here</p>
</div>
Try It Yourself

How It Works

  1. Make a scroll box. overflow: auto and a fixed height create a scroll container.
  2. Keep auto. overflow-anchor: auto is the default and allows anchoring.
  3. Insert content above later. In a supporting browser, the scroll offset can adjust so “Reading here” stays in place.
  4. You often write nothing. Many pages never set this property because the default already helps.

Example 2 — Opt Out of Anchoring

Turn anchoring off on a scroll container when the default behavior fights your layout.

CSS
<style>
  .feed {
    height: 120px;
    overflow: auto;
    overflow-anchor: none;
    border: 1px solid #cbd5e1;
  }
</style>

<div class="feed">
  <p>Older item</p>
  <p>Reading here</p>
</div>
Try It Yourself

How It Works

  1. Same scroll setup. The box still scrolls with overflow: auto.
  2. Set none. overflow-anchor: none opts this container out of anchoring.
  3. Inserts can jump. Content added above may push the reading line down instead of adjusting scroll.
  4. Use when auto feels wrong. Custom scroll scripts and some dynamic feeds need the opt-out.

Example 3 — Exclude One Changing Element

Keep anchoring for most content, but exclude a banner that resizes above the feed.

CSS
<style>
  .feed {
    height: 120px;
    overflow: auto;
    border: 1px solid #cbd5e1;
  }
  .banner {
    overflow-anchor: none;
  }
</style>

<div class="feed">
  <div class="banner">Promo banner</div>
  <p>Reading here</p>
</div>
Try It Yourself

How It Works

  1. Leave the feed on auto. Most content can still participate in anchoring.
  2. Target the noisy element. The banner is the piece that grows or swaps often.
  3. Set none on that element. overflow-anchor: none means the banner is not chosen as the anchor node.
  4. Prefer local opt-outs. Excluding one element is usually safer than turning anchoring off for the whole page.

Edge Cases & Pitfalls

If scroll still jumps, or anchoring seems to do nothing, check these first.

default

You rarely need to set auto

Anchoring is already enabled where supported. Writing overflow-anchor: auto is mostly for teaching or resetting after none.

scope

Prefer element opt-outs over *

A global * { overflow-anchor: none; } turns the feature off everywhere. Exclude only the element that causes bad jumps when you can.

overflow

Not a replacement for overflow

overflow still decides clipping and scrollbars. Anchoring only adjusts scroll position after content above changes.

safari

Older Safari has no anchoring

Support lands in Safari 27. On older Safari, inserts above the fold can still jump. Design layouts so critical reading is not overly sensitive to late-loading banners.

scripts

Custom scroll code can fight anchoring

If your script constantly sets scrollTop, browser anchoring may feel unpredictable. Opt out with none on that container, or stop fighting the browser’s adjustments.

Browser Support

overflow-anchor is a browser CSS property for scroll anchoring. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Newly available

overflow-anchor

Chrome 56+, Firefox 66+, Edge 79+, Opera 43+, Safari 27+. Internet Explorer has no support. Enabled by default where implemented.

80% Global browser support
Google Chrome 56+
Full support
Mozilla Firefox 66+
Full support
Apple Safari 27+
Full support
Microsoft Edge 79+
Full support
Opera 43+
Full support
Samsung Internet 6.2+
Full support
Internet Explorer No support
No support
overflow-anchor Newly available

Bottom line: Safe as a progressive enhancement. Leave auto as the default; use none only to opt out. It is not a runtime API.

Key Takeaways

  • Role: opt in or out of scroll anchoring when content above the viewport changes.
  • Initial value: auto. Anchoring is on by default where supported.
  • Main knob: set none only when you need to exclude an element or container.
  • Not overflow: anchoring adjusts scroll position; overflow controls clip and scrollbars.

One line: leave auto alone unless jumps appear — then opt out with none on the noisy element.

Frequently Asked Questions

It controls scroll anchoring. With auto (the default), the browser may adjust scroll position when content above the visible area changes, so what you were reading stays in place. With none, that element is not used as an anchor.
The initial value is auto. Scroll anchoring is on by default in browsers that support it, so you usually only set this property to opt out with none.
Use none when scroll anchoring causes unwanted jumps or fights your own scroll logic, such as custom scroll containers, sticky toolbars that resize, or elements that change height often above the viewport.
No. overflow controls clipping and scrollbars. overflow-anchor only decides whether an element can be a scroll anchor when content shifts.
No. Where supported, it is enabled by default. Set overflow-anchor only when you need to turn it off for a document or a specific element.
It is Baseline Newly available: Chrome 56+, Firefox 66+, Edge 79+, Opera 43+, and Safari 27+. Internet Explorer does not support it. It is a browser CSS property, not a Node.js feature.

Next: overflow-wrap

Learn how to break long words so they fit inside a line box.

overflow-wrap 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.

8 people found this page helpful