CSS overscroll-behavior-y Property

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

What You’ll Learn

The overscroll-behavior-y property controls what happens when a scrollable element reaches its vertical edge. It is essential for modals, chat panels, feed lists, and any nested area that scrolls up and down inside a larger page.

01

Physical Y Axis

Top and bottom edges.

02

Three Values

auto to none.

03

Default auto

Browser defaults.

04

Scroll Chaining

Stop parent scroll.

05

Modals & Chat

Vertical scroll UI.

06

Physical X Axis

Horizontal counterpart.

Introduction

The overscroll-behavior-y property in CSS is used to control the behavior of a scrolling container when the scroll position reaches the edge of the content along the vertical axis.

This property is particularly useful for preventing the default “bounce” or “pull-to-refresh” behavior on touch devices or when working with nested scrollable elements. By setting this property, developers can enhance the user experience by providing a more controlled and consistent scrolling behavior.

By customizing the overscroll behavior, developers can prevent unexpected scrolling actions, such as scrolling the entire page when reaching the end of a nested scrollable element.

Definition and Usage

Use overscroll-behavior-y on elements that scroll vertically inside a larger page, such as modal bodies, chat panels, off-canvas drawers, and nested feed lists.

Pair it with overflow-y: auto or overflow: auto so the element actually scrolls on the vertical axis. Then set overscroll-behavior-y: contain to keep vertical edge scrolling inside that box.

The overscroll-behavior shorthand sets both physical axes at once. In horizontal writing modes, overscroll-behavior-block is the logical equivalent of the vertical axis. Use overscroll-behavior-x when you need to control horizontal overscroll separately.

💡
Beginner Tip

Create a 300px-wide, 200px-tall box with 400px-tall content and overflow: auto;. Scroll to the bottom edge and keep scrolling to feel vertical scroll chaining, then add overscroll-behavior-y: contain;.

📝 Syntax

The syntax for the overscroll-behavior-y property is straightforward and can be applied to any scrollable container.

syntax.css
element {
  overscroll-behavior-y: value;
}

It can be applied to any scrollable element. Here, value can be one of the predefined keywords described below.

Basic Example

overscroll-behavior-y.css
.scroll-container {
  width: 300px;
  height: 200px;
  overflow: auto;
  overscroll-behavior-y: contain;
}
.content {
  height: 400px;
  background: linear-gradient(#e66465, #9198e5);
}

Syntax Rules

  • Accepted values: auto, contain, and none.
  • The element must be scrollable on the vertical axis, usually with overflow-y: auto or overflow: auto.
  • overscroll-behavior is a shorthand for overscroll-behavior-x and overscroll-behavior-y.
  • In horizontal writing mode, overscroll-behavior-block maps to the same axis as overscroll-behavior-y.
  • contain is the most common choice for modal bodies, chat panels, and nested vertical scroll lists.

🎯 Default Value

The default value of the overscroll-behavior-y property is auto. This means the default scroll behavior of the browser will occur when the scroll reaches the edge of the content.

With auto, scrolling past the top or bottom edge of a nested scroll area may chain to the page behind it or trigger platform-specific bounce effects.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toNon-replaced block and inline elements
InheritedNo
AnimatableNo
Physical axisVertical (top / bottom)
Common useModal bodies, chat panels, drawers, nested feed lists, vertical scroll panels

💎 Property Values

ValueExampleDescription
autooverscroll-behavior-y: auto;The default behavior of the browser is maintained. Scroll events are propagated normally.
containoverscroll-behavior-y: contain;The scroll behavior is contained within the element. The element does not allow scrolling beyond the boundaries, and the default bounce or pull-to-refresh behavior is disabled.
noneoverscroll-behavior-y: none;All scroll overflow effects are disabled. The element does not allow any scroll chaining or scroll overflow effects.
auto — default contain — stop chaining none — no bounce

👀 Live Preview

Three scroll boxes with the same tall gradient content and different overscroll-behavior-y values. Scroll each box to its top or bottom edge:

auto
contain
none

Examples Gallery

Prevent vertical scroll overflow with contain, compare default auto behavior, disable vertical bounce and pull-to-refresh with none, and isolate scroll inside a modal or chat body.

🔄 Vertical Containment

Use overscroll-behavior-y: contain when vertically scrollable areas should not scroll the page behind them.

Example 1 — Scrollable Container with contain

In this example, we prevent the vertical scroll overflow behavior on a container element.

overscroll-y-contain.html
<style>
  .scroll-container {
    width: 300px;
    height: 200px;
    overflow: auto;
    border: 1px solid #ccc;
    overscroll-behavior-y: contain;
  }
  .content {
    height: 400px;
    background: linear-gradient(#e66465, #9198e5);
  }
</style>

<div class="scroll-container">
  <div class="content"></div>
</div>
Try It Yourself

How It Works

In this example, the .scroll-container has a fixed height with overflow enabled. The overscroll-behavior-y: contain; property ensures that the user cannot scroll beyond the top or bottom of the container, preventing the default bounce effect.

Example 2 — Default auto Behavior

With overscroll-behavior-y: auto, the browser keeps its normal vertical overscroll behavior, including scroll chaining where supported.

overscroll-y-auto.css
.panel {
  width: 300px;
  height: 160px;
  overflow: auto;
  overscroll-behavior-y: auto;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
}
Try It Yourself

How It Works

When the panel hits its vertical scroll boundary, the browser may pass the scroll gesture to the page behind it.

🚫 Bounce & Vertical UI

Disable vertical bounce and pull-to-refresh with none or isolate vertical scroll inside modal and chat layouts.

Example 3 — Disable Vertical Overscroll with none

Use overscroll-behavior-y: none when you want to stop both vertical scroll chaining and overscroll bounce effects. On mobile, this can also help prevent pull-to-refresh when overscrolling at the top of a nested panel.

overscroll-y-none.css
.feed {
  width: 320px;
  height: 180px;
  overflow: auto;
  overscroll-behavior-y: none;
  border: 1px solid #334155;
  border-radius: 0.75rem;
}
Try It Yourself

How It Works

Neither the feed panel nor the page responds to vertical overscroll actions at the container edges, and pull-to-refresh is less likely to trigger on touch devices.

Example 4 — Modal or Chat Scroll Body

Keep nested vertical scroll inside a modal or chat body with overscroll-behavior-y: contain so the page behind stays still.

modal-scroll.css
.modal-body {
  max-height: 240px;
  overflow: auto;
  overscroll-behavior-y: contain;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
}
Try It Yourself

How It Works

The modal or chat body scrolls independently on the vertical axis while edge scrolling does not move the page behind the overlay.

overscroll-behavior vs block vs x

The overscroll-behavior shorthand sets both physical axes at once. overscroll-behavior-y targets only the vertical axis (top and bottom), and overscroll-behavior-x targets only the horizontal axis (left and right). In horizontal writing modes, overscroll-behavior-block is the logical equivalent of the vertical axis.

scroll-companion.css
/* Shorthand — both physical axes */
.modal-body {
  overscroll-behavior: contain;
}

/* Vertical axis only */
.chat-panel {
  overscroll-behavior-x: auto;
  overscroll-behavior-y: contain;
}

♿ Accessibility

  • Do not trap users — Preventing vertical scroll chaining is helpful in modals and chat panels, but ensure keyboard users can still scroll nested regions with arrow keys or focus management.
  • Keep scrollable regions discoverable — Pair overscroll control with visible scroll cues and sufficient contrast on vertically scrollable content.
  • Prefer contain on modal bodies — so background page movement does not disorient screen reader users when scrolling nested panels.
  • Test touch devices — Vertical overscroll behavior is especially noticeable on swipe gestures in modals, drawers, and chat interfaces.

🧠 How overscroll-behavior-y Works

1

User scrolls vertically

A modal body, chat panel, or feed list scrolls up and down while content fits inside its bounds.

Scroll
2

Scroll reaches the top or bottom edge

The inner container can scroll no farther up or down on the vertical axis.

Boundary
3

overscroll-behavior-y is applied

The browser decides whether to chain vertical scroll, bounce, or stop at the container edge.

Value
=

Controlled vertical overscroll

Vertically scrollable panels stay isolated from the page behind them when you use contain or none on the Y axis.

Browser Compatibility

The overscroll-behavior-y property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Edge, and Opera. Safari support has improved in recent versions, but testing across different browsers is recommended for consistent behavior.

Baseline · Modern browsers

Strong support in current browsers

auto, contain, and none work reliably in all major evergreen browsers. Modern Safari has improved support compared to older releases.

95% Global browser support
Google Chrome 63+ · 2017 onward
Full support
Mozilla Firefox 59+ · 2018 onward
Full support
Apple Safari 16+ · macOS & iOS
Improved support
Microsoft Edge 18+ · Chromium Edge
Full support
Opera 50+ · 2018 onward
Full support
overscroll-behavior-y property 95% supported

Bottom line: overscroll-behavior-y is dependable for vertical scroll UX in modern projects. Test on Safari and mobile browsers to confirm bounce and pull-to-refresh behavior.

Conclusion

The overscroll-behavior-y property provides developers with greater control over the scrolling behavior of web pages and applications.

By using this property, you can create a smoother and more predictable scrolling experience, especially on touch devices. Experiment with the different values to see how they affect your layout and user interactions.

💡 Best Practices

✅ Do

  • Use overscroll-behavior-y: contain on modal bodies, chat panels, and nested feed lists
  • Pair with overflow-y: auto or overflow: auto
  • Test scroll edges on touch devices and trackpads with vertical gestures
  • Use none when vertical bounce or pull-to-refresh feels distracting on nested panels
  • Combine with the overscroll-behavior shorthand when both axes need the same value

❌ Don’t

  • Expect overscroll control without a vertically scrollable container
  • Apply none everywhere when contain is enough
  • Confuse overscroll-behavior-y with overflow-y
  • Forget keyboard navigation for vertically scrollable regions
  • Skip cross-browser testing on Safari and mobile Chrome

Key Takeaways

Knowledge Unlocked

Five things to remember about overscroll-behavior-y

Use these points when vertically scrollable areas reach their edges.

5
Core concepts
02

Default auto

Browser defaults.

Default
📝 03

Three Values

auto to none.

Values
🚫 04

contain Modals

Stop vertical chaining.

Use case
05

Shorthand Pair

X + Y axes.

Companion

❓ Frequently Asked Questions

overscroll-behavior-y controls what happens when a scrollable element reaches its vertical boundary, such as whether up-down scroll chains to a parent or triggers bounce and pull-to-refresh effects.
The default value is auto, which means the browser uses its normal overscroll behavior on the vertical axis, including scroll chaining where supported.
overscroll-behavior-y targets the physical vertical axis (top and bottom). overscroll-behavior-x targets the physical horizontal axis. overscroll-behavior-block is the logical equivalent of the vertical axis in horizontal writing modes. The overscroll-behavior shorthand sets both x and y at once.
Use contain to stop vertical scroll chaining while still allowing local bounce effects. Use none when you also want to disable vertical bounce and prevent actions like pull-to-refresh on mobile.
Yes. Modern mobile browsers support overscroll-behavior-y, which is especially useful for modals, chat panels, and nested scroll areas where vertical overscroll should not move the page behind.

Practice in the Live Editor

Open the HTML editor and experiment with overscroll-behavior-y: contain, auto, and none on vertically scrollable areas.

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