CSS overflow-anchor Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Scrolling & Layout

What You’ll Learn

The overflow-anchor property controls scroll anchoring, which keeps your reading position stable when content above you changes on the page.

01

Scroll Anchoring

Stable scroll view.

02

auto Default

Browser decides.

03

none Value

Disable anchoring.

04

Dynamic Content

Loading & updates.

05

Scroll Containers

Works on overflow.

06

UX Control

Prevent jumps.

Introduction

The overflow-anchor property in CSS is designed to control the behavior of scroll anchoring, which is a feature that helps maintain the user’s scroll position when content changes dynamically.

This property ensures that the user’s view remains consistent and predictable when elements on the page are resized or added. This is particularly useful for improving the user experience on pages where content is dynamically loaded or updated.

Definition and Usage

Imagine reading a long feed while an image or ad loads above your current position. Scroll anchoring tries to keep the same content in view so the page does not jump unexpectedly.

Use overflow-anchor: none when that automatic adjustment causes problems in a custom scroll area or specialized UI.

💡
Beginner Tip

Most pages work fine with the default auto. You only need none when scroll anchoring interferes with a specific layout behavior.

📝 Syntax

The overflow-anchor property can be applied to any scrollable element. The syntax is as follows:

syntax.css
element {
  overflow-anchor: auto | none;
}

Here, the value can be auto or none.

Basic Example

overflow-anchor.css
.dynamic-content {
  overflow-anchor: none;
  overflow-y: auto;
}

Syntax Rules

  • auto lets the browser apply scroll anchoring when appropriate.
  • none disables scroll anchoring for that element.
  • Most useful on scroll containers with changing content above the viewport.
  • Works alongside overflow, not as a replacement for it.

🎯 Default Value

The default value of the overflow-anchor property is auto. This means that the browser will apply default scroll anchoring behavior.

In most cases you do not need to change this unless anchoring causes unwanted scroll adjustments.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toElements that can participate in scroll anchoring
InheritedNo
AnimatableNo
Common useControlling scroll stability in dynamic layouts

💎 Property Values

ValueExampleDescription
autooverflow-anchor: auto;The browser automatically determines when scroll anchoring should be applied (default)
noneoverflow-anchor: none;Scroll anchoring is disabled for the element
auto — browser anchoring none — disable anchoring

👀 Live Preview

A scrollable panel with overflow-anchor: none (anchoring disabled for this container):

Dynamic content area

Scroll anchoring is turned off here. Content above may shift the view differently when the box updates.

Line 3 of sample content.

Line 4 of sample content.

Line 5 of sample content.

Examples Gallery

Disable anchoring on dynamic panels, keep defaults, and compare use cases.

⚗ Scroll Anchoring Basics

Control anchoring on scrollable dynamic content.

Example 1 — Disable Scroll Anchoring

In this example, we disable scroll anchoring on a section of a page to prevent unexpected jumps when content dynamically updates.

anchor-none.html
<style>
  .dynamic-content {
    overflow-anchor: none;
    height: 200px;
    border: 1px solid #ccc;
    overflow-y: auto;
  }
</style>

<div class="dynamic-content">
  <p>Content that might change...</p>
</div>
Try It Yourself

How It Works

The browser will not try to preserve scroll position through anchoring inside this container.

Example 2 — Default auto Behavior

Leave the default in place when you want the browser to stabilize scroll during layout shifts.

anchor-auto.css
.article {
  overflow-anchor: auto;
}
Try It Yourself

How It Works

You usually do not need to set auto explicitly because it is already the default.

💬 Real-World Use Cases

Feeds and custom scroll areas where anchoring matters.

Example 3 — Chat or Feed Container

Scrollable feeds often rely on default anchoring so new content above does not disorient readers.

feed-anchor.css
.feed {
  max-height: 320px;
  overflow-y: auto;
  overflow-anchor: auto;
}
Try It Yourself

How It Works

Default anchoring helps keep the visible messages stable when older items load above.

Example 4 — Custom Sortable List

Disable anchoring when your own JavaScript manages scroll position during reordering.

list-anchor.css
.sortable-list {
  overflow-y: auto;
  overflow-anchor: none;
}
Try It Yourself

How It Works

With anchoring off, your script has full control over scroll position during DOM updates.

Works with overflow scroll containers

overflow-anchor does not create scrolling by itself. It affects how scroll position behaves inside containers that already use overflow.

scroll-container.css
.panel {
  height: 240px;
  overflow-y: auto;
  overflow-anchor: none;
}

♿ Accessibility

  • Reduce unexpected movement — Scroll anchoring can help users with vestibular sensitivity by limiting jarring jumps.
  • Test dynamic updates — Ensure content changes do not hide focused or important information.
  • Do not disable without reason — Turning off anchoring may reintroduce layout jumps.
  • Pair with clear loading states — When content shifts, visual feedback helps all users.

🧠 How overflow-anchor Works

1

User scrolls into content

They read or interact partway down a scrollable page or panel.

Scroll
2

Content above changes

Images load, ads appear, or new items are inserted higher in the DOM.

Change
3

Browser adjusts or skips anchoring

auto preserves view stability; none disables that behavior.

Anchor
=

Predictable scroll experience

Users stay oriented while dynamic content updates around them.

Browser Compatibility

The overflow-anchor property is supported in most modern browsers, including the latest versions of Chrome, Firefox, and Edge. Test your implementation across browsers to ensure consistent behavior.

Baseline · Modern browsers

Good support in current browsers

Scroll anchoring control works in up-to-date Chrome, Firefox, Edge, and Safari versions.

92% Modern browser support
Google Chrome 56+ · Desktop & Mobile
Full support
Mozilla Firefox 66+ · Desktop & Mobile
Full support
Apple Safari 15.4+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Internet Explorer No support
None
overflow-anchor property 92% supported

Bottom line: Safe to use as progressive enhancement for scroll stability in modern projects.

Conclusion

The overflow-anchor property is a valuable tool for managing scroll behavior in dynamically updated content.

By controlling whether scroll anchoring is applied, you can create a smoother and more predictable user experience. Whether you choose to use the default automatic anchoring or disable it entirely, this property helps maintain the stability of the user’s view during content changes.

💡 Best Practices

✅ Do

  • Keep the default auto unless you have a specific issue
  • Use none when JavaScript manages scroll position
  • Pair with scroll containers using overflow-y: auto
  • Test pages with lazy-loaded images and ads
  • Document why anchoring is disabled in custom UIs

❌ Don’t

  • Confuse overflow-anchor with overflow
  • Disable anchoring on every page by default
  • Expect it to fix layout bugs caused by missing sizes
  • Assume identical behavior in every browser without testing
  • Forget that dynamic content can still shift layout visually

Key Takeaways

Knowledge Unlocked

Five things to remember about overflow-anchor

Use these points when managing scroll stability.

5
Core concepts
02

Default auto

Browser handles it.

Default
📝 03

none Disables

Turn off anchoring.

Values
🔄 04

Dynamic Content

Main use case.

Use case
🗃 05

With overflow

Scroll containers.

Companion

❓ Frequently Asked Questions

overflow-anchor controls scroll anchoring, which helps keep the user's view stable when content above their scroll position changes.
The default value is auto, which lets the browser apply scroll anchoring when appropriate.
Use none when scroll anchoring causes unwanted jumps, such as in custom scroll containers or certain dynamic layouts.
It applies to scroll containers and elements that participate in scroll anchoring within a scrollable area.
No. overflow controls clipping and scrollbars, while overflow-anchor controls whether the browser adjusts scroll position when content changes.

Practice in the Live Editor

Open the HTML editor and experiment with overflow-anchor: auto and none on scroll containers.

HTML Editor →

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.

5 people found this page helpful