CSS overflow Property Explained

What the CSS overflow property does, with an example.

Published November 4, 2026

overflow controls what happens when content is bigger than its box: visible (default), hidden, scroll or auto.

How it works

auto shows scrollbars only when needed; hidden clips the extra content; scroll always shows scrollbars. overflow-x and overflow-y set each axis.

Setting overflow other than visible creates a new block formatting context.

Values and effects

overflow: visible; → content spills out
overflow: hidden; → clipped
overflow: scroll; → always scrollbars
overflow: auto; → scrollbars when needed
overflow: clip; → clip without scroll container

Practical examples

Scrollable panel

.panel { max-height: 300px; overflow-y: auto; }

Clip rounded images

.card { border-radius: 12px; overflow: hidden; }

Prevent horizontal scroll

html, body { overflow-x: hidden; }

Common mistakes

  • Hiding overflow to mask layout bugs.
  • Breaking position: sticky with overflow on ancestors.
  • Missing a fixed height so nothing overflows.

Key takeaways

  • overflow in one line: overflow controls what happens when content is bigger than its box: visible (default), hidden, scroll or auto.
  • Inspect it live in DevTools → Styles.
  • Test across browsers and screen sizes.

FAQ

Why does sticky stop working?

An ancestor with overflow other than visible changes the scroll container.

Is overflow supported in all browsers?

Yes in all modern browsers; check caniuse.com for edge cases.

More CSS articles