CSS overscroll-behavior-inline Property

The CSS overscroll-behavior-inline property controls scroll chaining and overscroll effects along an element's logical inline axis.

The inline axis follows the direction in which text and other inline content progresses. In horizontal writing modes, it is horizontal. In vertical writing modes, it is vertical. This property is useful for independently scrolling navigation bars, carousels, panels, and layouts that support different writing modes.

overscroll-behavior-inline Syntax

The overscroll-behavior-inline property accepts one keyword that determines how scrolling behaves when a scroll container reaches a boundary along its logical inline axis.

Basic Syntax

selector {
  overscroll-behavior-inline: contain;
}

Keyword Values

.panel {
  overscroll-behavior-inline: auto;
}
.panel {
  overscroll-behavior-inline: contain;
}
.panel {
  overscroll-behavior-inline: none;
}

CSS-Wide Keywords

.panel {
  overscroll-behavior-inline: initial;
}
.panel {
  overscroll-behavior-inline: inherit;
}
.panel {
  overscroll-behavior-inline: unset;
}
.panel {
  overscroll-behavior-inline: revert;
}
.panel {
  overscroll-behavior-inline: revert-layer;
}

The initial value is auto, which allows the browser's normal scroll chaining and overscroll effects.

Property Values

Value Description
auto Allows normal scroll chaining and overscroll effects along the inline axis.
contain Prevents scroll chaining to ancestor scroll containers while allowing local overscroll effects.
none Prevents scroll chaining and suppresses local overscroll effects along the inline axis.
initial Resets the property to auto.
inherit Uses the computed value of the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Scroll containers
Computed value Specified keyword
Animation type Discrete
Logical axis Inline axis
Physical equivalent overscroll-behavior-x or overscroll-behavior-y, depending on writing mode
Length values Not accepted
Percentage values Not accepted

Valid Values

.panel {
  overscroll-behavior-inline: auto;
}
.panel {
  overscroll-behavior-inline: contain;
}
.panel {
  overscroll-behavior-inline: none;
}

Invalid Values

.panel {
  overscroll-behavior-inline: hidden;
}
.panel {
  overscroll-behavior-inline: 10px;
}
.panel {
  overscroll-behavior-inline: contain none;
}

Only one overscroll keyword is accepted. The two-value syntax belongs to the overscroll-behavior shorthand.

How It Works

When a user scrolls along the inline axis, the browser moves the content until the scroll container reaches its boundary.

Additional scrolling may normally continue into an ancestor scroll container or trigger a local overscroll effect. The overscroll-behavior-inline property controls these actions.

Default Behavior

.gallery {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  overscroll-behavior-inline: auto;
}

In horizontal writing mode, the inline axis is horizontal. Additional horizontal scrolling may continue into an ancestor scroll container when the gallery reaches its boundary.

Preventing Scroll Chaining

.gallery {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

Horizontal scroll chaining is prevented in horizontal writing mode, while scrolling inside the gallery remains available.

Suppressing Overscroll Effects

.gallery {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  overscroll-behavior-inline: none;
}

This prevents scroll chaining and suppresses local overscroll effects along the inline axis.

Important Consideration

The property does not create scrolling or change the amount of scrollable content. The element must establish a scroll container for the setting to have an effect.

Understanding the Inline Axis

The inline axis is the direction along which inline content flows. Its physical orientation depends on the element's writing-mode.

Writing Mode Inline Axis Physical Equivalent
horizontal-tb Horizontal overscroll-behavior-x
vertical-rl Vertical overscroll-behavior-y
vertical-lr Vertical overscroll-behavior-y
sideways-rl Vertical overscroll-behavior-y
sideways-lr Vertical overscroll-behavior-y

Horizontal Writing Mode

.panel {
  writing-mode: horizontal-tb;
  overscroll-behavior-inline: contain;
}

The property controls horizontal overscroll behavior.

Vertical Writing Mode

.panel {
  writing-mode: vertical-rl;
  overscroll-behavior-inline: contain;
}

The property controls vertical overscroll behavior.

Text Direction

.panel {
  direction: rtl;
  overscroll-behavior-inline: contain;
}

Changing text direction can reverse inline progression, but it does not change the physical orientation of the inline axis. In horizontal writing mode, the inline axis remains horizontal.

Controlling Scroll Chaining

Scroll chaining occurs when a scroll container reaches its boundary and additional scrolling continues into an ancestor scroll container.

Allowing Scroll Chaining

.scroll-panel {
  overflow-x: auto;
  overscroll-behavior-inline: auto;
}

In horizontal writing mode, continued horizontal scrolling may move an ancestor container after the inner panel reaches its boundary.

Preventing Scroll Chaining

.scroll-panel {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

The panel continues to scroll normally, but horizontal scrolling does not chain into an ancestor when the panel reaches its boundary.

Preventing Chaining and Overscroll Effects

.scroll-panel {
  overflow-x: auto;
  overscroll-behavior-inline: none;
}

The none value also suppresses local overscroll effects along the inline axis.

Common Uses

  • Horizontally scrolling navigation bars.
  • Image galleries and carousels.
  • Scrollable code examples.
  • Wide data tables.
  • Interfaces supporting vertical writing modes.

Important Consideration

Scroll chaining is most noticeable when nested containers can scroll along the same physical axis. The effect may be less apparent when the surrounding page scrolls only vertically and the inner container scrolls horizontally.

Controlling Overscroll Effects

Browsers may display a visual or interactive effect when users attempt to scroll beyond a scroll boundary.

Allowing Normal Effects

.panel {
  overscroll-behavior-inline: auto;
}

Normal scroll chaining and overscroll effects remain available.

Allowing Local Effects Only

.panel {
  overscroll-behavior-inline: contain;
}

Scroll chaining is prevented, but local effects such as elastic bouncing may remain available.

Suppressing Local Effects

.panel {
  overscroll-behavior-inline: none;
}

Both scroll chaining and local overscroll effects are suppressed along the inline axis.

Browser Differences

Overscroll effects vary between browsers, operating systems, and input devices. Some platforms do not display a visible effect even when the value is auto.

Important Consideration

The property does not disable ordinary scrolling. Users can still move through scrollable content until reaching a boundary.

Logical vs. Physical Properties

Physical overscroll properties control fixed horizontal and vertical axes. Logical properties follow the element's writing mode.

Property Controlled Axis
overscroll-behavior-x Physical horizontal axis
overscroll-behavior-y Physical vertical axis
overscroll-behavior-inline Logical inline axis
overscroll-behavior-block Logical block axis

Physical Property

.panel {
  overscroll-behavior-x: contain;
}

This always controls horizontal overscroll, regardless of writing mode.

Logical Property

.panel {
  overscroll-behavior-inline: contain;
}

This controls horizontal overscroll in horizontal writing modes and vertical overscroll in vertical writing modes.

Controlling Both Logical Axes

.panel {
  overscroll-behavior-inline: contain;
  overscroll-behavior-block: auto;
}

Inline-axis scroll chaining is prevented while block-axis overscroll retains its default behavior.

Using the Shorthand

.panel {
  overscroll-behavior: contain auto;
}

The shorthand controls the physical x-axis and y-axis, in that order. It is not a logical inline/block shorthand.

Writing Modes

The writing-mode property determines whether inline content progresses horizontally or vertically.

Horizontal Writing Mode

.horizontal-gallery {
  writing-mode: horizontal-tb;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

The inline axis is horizontal, so the property prevents horizontal scroll chaining.

Vertical Writing Mode

.vertical-panel {
  writing-mode: vertical-rl;
  height: 200px;
  overflow-y: auto;
  overscroll-behavior-inline: contain;
}

The inline axis is vertical, so the property prevents vertical scroll chaining.

Writing-Mode-Aware Sizing

.panel {
  max-inline-size: 250px;
  overflow-inline: auto;
  overscroll-behavior-inline: contain;
}

These logical properties follow the inline axis. Check compatibility for overflow-inline before relying on it in production.

Important Consideration

Writing mode affects text flow, layout, and scrolling orientation. Use the writing mode appropriate for the content rather than changing it solely to control overscroll behavior.

overscroll-behavior-inline Example

This example compares the three keyword values using horizontally scrollable panels.

Scroll each panel to its horizontal boundary, then continue scrolling. The differences affect scroll chaining and local overscroll effects supported by your browser.

HTML Example

<div class="inline-demo">
  <div class="inline-item">
    <h3>auto</h3>
    <div class="inline-panel inline-auto" tabindex="0">
      <span>Item 1</span>
      <span>Item 2</span>
      <span>Item 3</span>
      <span>Item 4</span>
      <span>Item 5</span>
    </div>
  </div>
  <div class="inline-item">
    <h3>contain</h3>
    <div class="inline-panel inline-contain" tabindex="0">
      <span>Item 1</span>
      <span>Item 2</span>
      <span>Item 3</span>
      <span>Item 4</span>
      <span>Item 5</span>
    </div>
  </div>
  <div class="inline-item">
    <h3>none</h3>
    <div class="inline-panel inline-none" tabindex="0">
      <span>Item 1</span>
      <span>Item 2</span>
      <span>Item 3</span>
      <span>Item 4</span>
      <span>Item 5</span>
    </div>
  </div>
</div>

CSS Example

.inline-demo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  padding: 20px;
  background-color: #f1f5f9;
}
.inline-item h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.inline-panel {
  display: flex;
  gap: 10px;
  box-sizing: border-box;
  padding: 12px;
  overflow-x: auto;
  border: 2px solid #64748b;
  background-color: #fff;
}
.inline-panel span {
  flex: 0 0 100px;
  padding: 15px 10px;
  background-color: #dbeafe;
  text-align: center;
}
.inline-auto {
  overscroll-behavior-inline: auto;
}
.inline-contain {
  overscroll-behavior-inline: contain;
}
.inline-none {
  overscroll-behavior-inline: none;
}
Browser Result

auto

Item 1 Item 2 Item 3 Item 4 Item 5

contain

Item 1 Item 2 Item 3 Item 4 Item 5

none

Item 1 Item 2 Item 3 Item 4 Item 5

All three panels scroll horizontally. Differences at their boundaries may be more noticeable on touchscreens and trackpads that support horizontal overscroll effects.

Vertical Writing Mode Example

The following example demonstrates how overscroll-behavior-inline controls vertical overscroll in a vertical writing mode.

<div class="vertical-inline-panel" tabindex="0">
  <p>First section of vertical text.</p>
  <p>Second section of vertical text.</p>
  <p>Third section of vertical text.</p>
</div>
.vertical-inline-panel {
  box-sizing: border-box;
  writing-mode: vertical-rl;
  width: 280px;
  max-width: 100%;
  height: 160px;
  padding: 15px;
  overflow-y: auto;
  overscroll-behavior-inline: contain;
  border: 2px solid #64748b;
  background-color: #f8fafc;
}
.vertical-inline-panel p {
  margin: 0 0 15px;
  padding: 10px;
  background-color: #dbeafe;
}
Browser Result

First section of vertical text.

Second section of vertical text.

Third section of vertical text.

In vertical-rl writing mode, the inline axis is vertical. The property prevents vertical scroll chaining when the container reaches its boundary. The visible effect depends on whether the content overflows vertically.

Accessibility Considerations

Scrollable content should remain accessible regardless of its writing mode or overscroll settings.

Maintain Keyboard Access

Ensure scrollable regions can be reached and operated using a keyboard. Add a focusable region when appropriate.

<div class="scroll-gallery" tabindex="0" role="region" aria-label="Scrollable gallery">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>

Provide Visible Focus Indicators

.scroll-gallery:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

Avoid Unnecessary Scroll Containment

Preventing scroll chaining can be useful for galleries and nested panels, but excessive containment may make navigation less convenient.

Provide Alternative Controls When Needed

For horizontal carousels or other complex scrolling interfaces, consider providing visible previous and next controls rather than relying exclusively on gestures.

Important Consideration

Overscroll settings should not prevent users from reaching content or controls with a keyboard, pointer, or touch input.

Common Mistakes

Assuming the Inline Axis Is Always Horizontal

The inline axis is horizontal in horizontal writing modes but vertical in vertical writing modes.

Applying the Property Without a Scroll Container

.box {
  overscroll-behavior-inline: contain;
}

This declaration does not create scrolling. The element must establish a scroll container for overscroll behavior to have an effect.

Confusing Overscroll with Overflow

The overflow properties control clipping and scrolling. The overscroll-behavior properties control behavior when scrolling reaches a boundary.

Using Invalid Values

.box {
  overscroll-behavior-inline: hidden;
}

The hidden keyword is invalid. Use auto, contain, or none.

Using Two Values

.box {
  overscroll-behavior-inline: contain none;
}

This longhand accepts only one keyword. Use separate logical longhands to control both axes.

Expecting contain to Remove All Effects

The contain value prevents scroll chaining but permits local overscroll effects. Use none to suppress those effects.

Overriding a Logical Property Accidentally

.panel {
  overscroll-behavior-inline: contain;
  overscroll-behavior-x: auto;
}

In horizontal writing mode, both declarations target the x-axis. The later declaration takes precedence when both have equal cascade priority.

Important Considerations

Keep the following points in mind when using overscroll-behavior-inline:

  • The property controls overscroll along the logical inline axis.
  • Its initial value is auto.
  • It is not inherited.
  • It applies to scroll containers.
  • It accepts auto, contain, and none.
  • Only one keyword is permitted.
  • auto allows normal scroll chaining and overscroll effects.
  • contain prevents scroll chaining while allowing local overscroll effects.
  • none prevents scroll chaining and suppresses local overscroll effects.
  • The inline axis depends on the element's writing mode.
  • In horizontal writing modes, the inline axis is horizontal.
  • In vertical writing modes, the inline axis is vertical.
  • Changing text direction alone does not change the axis orientation.
  • The property does not create a scroll container.
  • It does not disable ordinary scrolling.
  • It is the logical counterpart of the physical overscroll properties.
  • Scrollable galleries and navigation bars are common use cases.
  • Browser overscroll effects vary by platform.
  • Scrollable regions should remain keyboard accessible.
  • Physical-property fallbacks may be useful for older browsers.

Browser Support

The CSS overscroll-behavior-inline property has limited availability compared with the physical overscroll-behavior-x and overscroll-behavior-y properties. Support varies across browsers and versions.

For broader compatibility, provide a physical-property fallback before the logical declaration.

Horizontal Writing Fallback

.gallery {
  overscroll-behavior-x: contain;
  overscroll-behavior-inline: contain;
}

In horizontal writing mode, both declarations control horizontal overscroll. Browsers without logical-property support can use the physical fallback.

Vertical Writing Fallback

.panel {
  writing-mode: vertical-rl;
  overscroll-behavior-y: contain;
  overscroll-behavior-inline: contain;
}

In vertical writing mode, the inline axis is vertical, so overscroll-behavior-y provides the appropriate fallback.

Feature Detection

@supports (overscroll-behavior-inline: contain) {
  .gallery {
    overscroll-behavior-inline: contain;
  }
}

For current compatibility information, visit Can I Use? and search for overscroll-behavior-inline.

Specifications

The overscroll-behavior-inline property is defined in CSS Overscroll Behavior Module Level 1.

CSS Overscroll Behavior Module Level 1

The specification defines physical and logical overscroll properties, scroll chaining, and overscroll effects.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: overscroll-behavior-inline