CSS overflow-block Property

The CSS overflow-block property controls how overflowing content is displayed along an element's logical block axis.

The block axis follows the element's writing mode. In horizontal writing modes, it is vertical. In vertical writing modes, it is horizontal. The property provides a writing-mode-aware alternative to using overflow-x or overflow-y directly.

overflow-block Syntax

The overflow-block property accepts one overflow keyword that controls content along the logical block axis.

Basic Syntax

selector {
  overflow-block: auto;
}

Keyword Values

.box {
  overflow-block: visible;
}
.box {
  overflow-block: hidden;
}
.box {
  overflow-block: clip;
}
.box {
  overflow-block: scroll;
}
.box {
  overflow-block: auto;
}

CSS-Wide Keywords

.box {
  overflow-block: initial;
}
.box {
  overflow-block: inherit;
}
.box {
  overflow-block: unset;
}
.box {
  overflow-block: revert;
}
.box {
  overflow-block: revert-layer;
}

The initial value is visible, which allows content to extend beyond the element's padding box along the block axis.

Property Values

Value Description
visible Allows content to extend beyond the padding box along the block axis. This is the initial value.
hidden Clips overflowing content without providing user-operated scrolling. Programmatic scrolling remains possible.
clip Clips overflowing content at the overflow clip edge without allowing scrolling along the clipped axis.
scroll Clips overflowing content and enables scrolling along the block axis.
auto Allows scrolling when content exceeds the available space along the block axis.
initial Resets the property to visible.
inherit Uses the computed value of the parent element.
unset Resets the property to visible 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 visible
Inherited No
Applies to Block containers, flex containers, and grid containers
Computed value Specified keyword, with adjustments based on overflow along the other axis
Animation type Discrete
Logical axis Block axis
Physical equivalent overflow-y or overflow-x, depending on writing mode

Valid Values

.box {
  overflow-block: visible;
}
.box {
  overflow-block: hidden;
}
.box {
  overflow-block: clip;
}
.box {
  overflow-block: scroll;
}
.box {
  overflow-block: auto;
}

Invalid Values

.box {
  overflow-block: none;
}
.box {
  overflow-block: 20px;
}
.box {
  overflow-block: hidden auto;
}

The property accepts one supported overflow keyword, not a length or a two-value combination.

How It Works

The overflow-block property determines whether content extending beyond the block-axis boundaries remains visible, is clipped, or can be scrolled.

Basic Scrollable Container

.content-panel {
  block-size: 200px;
  overflow-block: auto;
}

The block-size property constrains the container along its block axis. If the content exceeds that space, scrolling becomes available when supported.

Clipping Overflow

.content-panel {
  block-size: 200px;
  overflow-block: hidden;
}

Content extending beyond the block-axis boundary is clipped.

Allowing Visible Overflow

.content-panel {
  block-size: 200px;
  overflow-block: visible;
}

Content can extend beyond the container when the other overflow axis does not cause the value to compute differently.

Important Consideration

The property does not establish a size constraint by itself. A constrained block-size, max-block-size, or other layout restriction is generally necessary to create a scrollable region.

Understanding the Block Axis

CSS uses logical axes to describe layout directions independently of physical horizontal and vertical coordinates.

Block Axis

The block axis is the direction in which block-level content progresses. For example, paragraphs normally stack from top to bottom in English-language pages.

Inline Axis

The inline axis is the direction in which text and other inline content progresses within a line.

Horizontal Writing Mode

.box {
  writing-mode: horizontal-tb;
  overflow-block: auto;
}

In this writing mode, the block axis is vertical, so overflow-block corresponds to overflow-y.

Vertical Writing Mode

.box {
  writing-mode: vertical-rl;
  overflow-block: auto;
}

In this writing mode, the block axis is horizontal, so overflow-block corresponds to overflow-x.

Direction vs. Axis

The block axis identifies a dimension, while the writing mode determines the direction of block progression. Changing the writing mode can change which physical axis the property controls.

visible Value

The visible value allows content to extend beyond the padding box along the block axis without clipping.

Basic Example

.box {
  block-size: 120px;
  overflow-block: visible;
}

Default Behavior

.box {
  overflow-block: visible;
}

This is the initial value.

When visible Is Useful

  • Allowing content to extend outside a container.
  • Preserving decorative elements that extend beyond an edge.
  • Avoiding unnecessary clipping or scrolling.

Important Consideration

If overflow along the inline axis is set to auto, scroll, or hidden, a specified visible value on the block axis computes to auto.

hidden Value

The hidden value clips content along the block axis and prevents direct user scrolling through that axis, while still permitting programmatic scrolling.

Basic Example

.box {
  block-size: 150px;
  overflow-block: hidden;
}

Clipping Dynamic Content

.preview-panel {
  max-block-size: 180px;
  overflow-block: hidden;
}

Programmatic Scrolling

const panel = document.querySelector(".preview-panel");
panel.scrollTop = 100;

In a horizontal writing mode, the block axis is vertical, so the scrollTop property controls programmatic scrolling along that axis.

Important Consideration

Clipped content may be inaccessible if no mechanism exists to reveal it. Do not use hidden to conceal essential content or interactive controls.

clip Value

The clip value clips content along the block axis without allowing scrolling along that axis.

Basic Example

.box {
  block-size: 150px;
  overflow-block: clip;
}

Using overflow-clip-margin

.box {
  overflow-block: clip;
  overflow-clip-margin: 8px;
}

Where applicable, overflow-clip-margin extends the clipping edge beyond the padding box.

clip vs. hidden

Behavior hidden clip
Clips overflow Yes Yes
User scrolling along the clipped axis No No
Programmatic scrolling along the clipped axis Yes No
Creates a scroll container by itself Yes No

Important Consideration

When the inline-axis overflow value is auto, scroll, or hidden, a specified clip value on the block axis computes to hidden.

scroll Value

The scroll value clips overflowing content and enables scrolling along the block axis.

Basic Example

.box {
  block-size: 200px;
  overflow-block: scroll;
}

Scrollable Reading Panel

.reading-panel {
  max-block-size: 300px;
  overflow-block: scroll;
}

Scrollbar Appearance

Traditional scrollbar systems may reserve space even when scrolling is unnecessary. Overlay scrollbar systems may display scrollbars only during interaction.

Important Consideration

Use scroll when a scrollable region is intended. If scrolling should be available only when needed, auto is often more appropriate.

auto Value

The auto value allows the browser to provide scrolling along the block axis when content exceeds the available space.

Basic Example

.box {
  max-block-size: 250px;
  overflow-block: auto;
}

Responsive Content Panel

.content-panel {
  max-block-size: 50vh;
  overflow-block: auto;
}

The panel can scroll when its content exceeds half the viewport height in a horizontal writing mode.

Using Logical Sizing

.content-panel {
  inline-size: 300px;
  block-size: 200px;
  overflow-block: auto;
}

Combining logical dimensions with logical overflow properties creates a layout that adapts more naturally to different writing modes.

Important Consideration

Scrollbar appearance depends on the browser and operating system. An auto value does not guarantee that a scrollbar will always be visible.

Writing Modes

The writing-mode property determines how text lines are arranged and how the block axis maps to physical directions.

Writing Mode Block Axis Physical Equivalent
horizontal-tb Vertical overflow-y
vertical-rl Horizontal overflow-x
vertical-lr Horizontal overflow-x
sideways-rl Horizontal overflow-x
sideways-lr Horizontal overflow-x

Horizontal Writing

.box {
  writing-mode: horizontal-tb;
  block-size: 200px;
  overflow-block: auto;
}

Vertical Writing

.box {
  writing-mode: vertical-rl;
  block-size: 200px;
  overflow-block: auto;
}

Changing Writing Modes

When the writing mode changes, the block axis changes automatically. This is the main advantage of logical overflow properties over physical overflow properties.

Important Consideration

The direction property affects inline text direction, but it does not independently change which physical dimension represents the block axis.

Logical vs. Physical Overflow

Physical overflow properties refer to fixed horizontal and vertical axes. Logical overflow properties follow the element's writing mode.

Physical Overflow

.box {
  overflow-y: auto;
}

This always targets the physical vertical axis.

Logical Overflow

.box {
  overflow-block: auto;
}

This targets the block axis, which may be vertical or horizontal.

Comparison

Property Axis Writing-Mode-Aware
overflow-x Physical horizontal No
overflow-y Physical vertical No
overflow-inline Logical inline Yes
overflow-block Logical block Yes

When Logical Overflow Is Useful

  • Multilingual websites supporting vertical writing modes.
  • Reusable components that should adapt to different writing directions.
  • Layouts that already use logical sizing and spacing properties.
  • Interfaces designed around block and inline axes rather than fixed physical directions.

overflow-block and overflow-inline

The overflow-block and overflow-inline properties work together to control overflow along both logical axes.

Block-Axis Scrolling

.box {
  overflow-block: auto;
  overflow-inline: hidden;
}

Inline-Axis Scrolling

.box {
  overflow-block: hidden;
  overflow-inline: auto;
}

Both Axes

.box {
  overflow-block: auto;
  overflow-inline: auto;
}

Computed Value Adjustments

.box {
  overflow-block: visible;
  overflow-inline: auto;
}

Because the inline axis uses auto, the specified block-axis value visible computes to auto.

Using clip with auto

.box {
  overflow-block: clip;
  overflow-inline: auto;
}

In this combination, the specified clip value computes to hidden.

Important Consideration

Logical overflow properties map to the same underlying overflow axes as overflow-x and overflow-y. Avoid conflicting declarations unless their cascade order is intentional.

Scroll Containers

A scroll container provides a scrollable viewing area when content exceeds the available space along a scrollable axis.

Creating a Scroll Container

.scroll-panel {
  block-size: 250px;
  overflow-block: auto;
}

Controlling Scrollbar Space

.scroll-panel {
  block-size: 250px;
  overflow-block: auto;
  scrollbar-gutter: stable;
}

The scrollbar-gutter property can reserve space for classic scrollbars to help reduce layout changes.

Using scroll-behavior

.scroll-panel {
  block-size: 250px;
  overflow-block: auto;
  scroll-behavior: smooth;
}

The scroll-behavior property can control the behavior of certain programmatic scrolling operations.

Important Consideration

Scrollable regions should remain accessible with keyboard, touch, and other supported input methods. Avoid unnecessarily restricting scrolling or hiding important content.

overflow-block Example

This example demonstrates how overflow-block behaves in horizontal and vertical writing modes. Both containers use auto, but the logical block axis maps to a different physical direction.

HTML Example

<div class="overflow-block-demo">
  <div class="overflow-block-item">
    <h3>Horizontal Writing</h3>
    <div class="overflow-block-box horizontal-box" tabindex="0">
      <p>First paragraph of content.</p>
      <p>Second paragraph of content.</p>
      <p>Third paragraph of content.</p>
      <p>Fourth paragraph of content.</p>
    </div>
  </div>
  <div class="overflow-block-item">
    <h3>Vertical Writing</h3>
    <div class="overflow-block-box vertical-box" tabindex="0">
      <p>First paragraph of content.</p>
      <p>Second paragraph of content.</p>
      <p>Third paragraph of content.</p>
      <p>Fourth paragraph of content.</p>
    </div>
  </div>
</div>

CSS Example

.overflow-block-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 20px;
  background-color: #f1f5f9;
}
.overflow-block-item {
  width: 250px;
}
.overflow-block-item h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.overflow-block-box {
  box-sizing: border-box;
  width: 250px;
  height: 150px;
  padding: 12px;
  border: 2px solid #64748b;
  background-color: #fff;
  color: #334155;
  overflow-block: auto;
}
.overflow-block-box p {
  margin: 0 0 12px;
}
.horizontal-box {
  writing-mode: horizontal-tb;
}
.vertical-box {
  writing-mode: vertical-rl;
}
Browser Result

Horizontal Writing

First paragraph of content.

Second paragraph of content.

Third paragraph of content.

Fourth paragraph of content.

Vertical Writing

First paragraph of content.

Second paragraph of content.

Third paragraph of content.

Fourth paragraph of content.

In the horizontal writing mode, block-axis overflow occurs vertically. In the vertical writing mode, block-axis overflow occurs horizontally. The actual presence of scrolling depends on the available space and browser support.

Comparing Overflow Values

The following example compares visible, hidden, and auto along the block axis in a horizontal writing mode.

<div class="block-value-demo">
  <div class="block-value-box block-visible">Visible overflow content that extends beyond the container.</div>
  <div class="block-value-box block-hidden">Hidden overflow content that extends beyond the container.</div>
  <div class="block-value-box block-auto">Scrollable overflow content that extends beyond the container.</div>
</div>
.block-value-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 35px;
  padding: 20px;
}
.block-value-box {
  box-sizing: border-box;
  width: 140px;
  height: 65px;
  padding: 10px;
  border: 2px solid #64748b;
  background-color: #dbeafe;
  writing-mode: horizontal-tb;
}
.block-visible {
  overflow-block: visible;
}
.block-hidden {
  overflow-block: hidden;
}
.block-auto {
  overflow-block: auto;
}
Browser Result
Visible overflow content that extends beyond the container.
Hidden overflow content that extends beyond the container.
Scrollable overflow content that extends beyond the container.

The visible box allows content to extend beyond its boundary. The hidden box clips excess content, while the auto box allows scrolling when needed.

Accessibility Considerations

Overflow handling should preserve access to content regardless of writing mode, viewport size, or input method.

Keyboard-Accessible Scroll Regions

<div class="scroll-region" tabindex="0" role="region" aria-label="Scrollable content">
  <p>Scrollable content goes here.</p>
</div>
.scroll-region {
  max-block-size: 250px;
  overflow-block: auto;
}
.scroll-region:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 2px;
}

Making a scroll region focusable can help keyboard users reach and operate it when necessary. Avoid unnecessary tab stops if the region is already keyboard-accessible.

Avoid Clipping Important Content

Using hidden or clip can make content inaccessible when there is no alternative way to reveal it.

Support Different Writing Modes

Test components in both horizontal and vertical writing modes when they are intended for multilingual or writing-mode-aware layouts.

Preserve Focus Indicators

Overflow clipping can hide focus outlines or other visual indicators. Verify that focused elements remain identifiable.

Important Consideration

Scrollable content should remain usable at increased browser zoom and on narrow screens. Avoid unnecessary nested scrolling regions.

Common Mistakes

Assuming the Block Axis Is Always Vertical

.box {
  writing-mode: vertical-rl;
  overflow-block: auto;
}

In a vertical writing mode, the block axis is horizontal.

Expecting Scrolling Without a Size Constraint

.box {
  overflow-block: auto;
}

If the element expands to fit its content, there may be no overflow to scroll.

Using Two Values

.box {
  overflow-block: hidden auto;
}

The property accepts only one value. Use the overflow shorthand for two physical-axis values.

Using Invalid Keywords

.box {
  overflow-block: none;
}

The none keyword is not valid.

Confusing clip with hidden

hidden permits programmatic scrolling, while clip prevents scrolling along the clipped axis.

Ignoring Computed Value Adjustments

Mixing visible or clip with scrolling values on the other axis can change their computed behavior.

Conflicting Logical and Physical Declarations

.box {
  overflow-y: hidden;
  overflow-block: auto;
}

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

Assuming Universal Browser Support

The logical overflow properties are newer than the physical overflow properties. Check compatibility before relying on them.

Important Considerations

Keep the following points in mind when using overflow-block:

  • The property controls overflow along the logical block axis.
  • Its initial value is visible.
  • The property is not inherited.
  • It accepts visible, hidden, clip, scroll, and auto.
  • It accepts one overflow value, not two.
  • The block axis depends on the element's writing mode.
  • In horizontal-tb, the block axis is vertical.
  • In vertical writing modes, the block axis is horizontal.
  • The physical equivalent is overflow-y or overflow-x, depending on writing mode.
  • visible allows content to extend beyond the container.
  • hidden clips overflow but permits programmatic scrolling.
  • clip clips overflow without allowing scrolling along that axis.
  • scroll enables scrolling along the block axis.
  • auto enables scrolling when needed.
  • Scrollable containers generally require appropriate size constraints.
  • Computed values may change based on overflow along the other axis.
  • overflow-inline controls the logical inline axis.
  • The overflow shorthand controls both physical axes.
  • Logical and physical overflow declarations can target the same underlying axis.
  • Overflow clipping can hide content, shadows, and focus indicators.
  • Scrollbar presentation depends on the browser and operating system.
  • Logical overflow properties are useful for writing-mode-aware interfaces.
  • Browser support is more limited than for overflow-x and overflow-y.
  • Test layouts in the writing modes and browsers they are intended to support.

Browser Support

The CSS overflow-block property has Limited availability and is not supported in every major browser.

Support for logical overflow properties is less consistent than support for the physical overflow-x and overflow-y properties. Browsers that do not recognize overflow-block ignore the declaration.

For layouts requiring broad compatibility, use the appropriate physical overflow property as a fallback. Keep in mind that a physical fallback does not automatically adapt to changes in writing mode.

Fallback Example

.box {
  writing-mode: horizontal-tb;
  overflow-y: auto;
  overflow-block: auto;
}

In horizontal writing mode, overflow-y provides the intended vertical scrolling behavior when overflow-block is unsupported.

For current compatibility information, visit Can I Use? and search for overflow-block.

Specifications

The overflow-block property is defined in CSS Overflow Module Level 3.

CSS Overflow Module Level 3: Overflow Control

The specification defines logical overflow properties and their relationship to physical overflow axes.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: overflow-block