Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Box Model and Sizing

The overflow-x property

Reference for the CSS overflow-x property: how content that is too wide is shown, clipped or scrolled, mixed-axis rules, examples and browser support.

The overflow-x property controls what happens when content is wider than its box. It decides whether the extra width is shown, clipped, or reachable with a horizontal scrollbar. It is the horizontal half of the overflow shorthand.

CSS
.table-wrap {
  overflow-x: auto;
}

Try it

Horizontal scrolling

The first strip can be scrolled sideways. The second shows the same row cut off at the box edge, with no scrollbar.

Syntax

CSS
overflow-x: visible | hidden | clip | scroll | auto
  • Initial value: visible
  • Applies to: block containers, flex containers and grid containers
  • Inherited: no
  • Animatable: no
  • Computed value: as specified, except visible becomes auto and clip becomes hidden if overflow-y is neither visible nor clip

Values

Value Description
visible Wide content is drawn outside the box.
hidden Content is clipped at the padding edge; no scrollbar, but it can still be scrolled programmatically.
clip Clipped with no scrolling at all; the box is not a scroll container.
scroll Clipped, with a horizontal scrollbar always present.
auto Clipped, with a horizontal scrollbar only when the content is wider than the box.

Usage notes

  • The two axes are linked. Setting overflow-x: auto while leaving overflow-y at visible makes overflow-y compute to auto. You cannot scroll sideways and let content spill out vertically.
  • Wide tables and code. Wrap a wide table or <pre> in a container with overflow-x: auto so only that element scrolls, not the whole page.
  • Page-level horizontal scroll. An unwanted sideways scrollbar on the page usually means some element is wider than the viewport. Find it with browser devtools; overflow-x: hidden on body only hides the symptom and can break position: sticky.
  • Long text. Wrapping rules (overflow-wrap, white-space) decide whether text overflows at all.
  • Keyboard users. Make scrollable regions focusable (tabindex="0") and name them so they can be scrolled with arrow keys.

Browser support

Supported in every browser; the clip keyword is supported in all current major browsers.