CSS overflow-y Property

Beginner
6 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The overflow-y property controls what happens when content overflows a block-level element’s top and bottom edges. You can let it paint outside, clip it, or allow vertical scrolling.

The initial value is visible. It is the vertical half of the overflow shorthand; pair it with overflow-x when axes must differ. The box needs a limited height or max-height or nothing overflows vertically.

Baseline · Widely available.

Not deprecated. Core keywords are standard-track. clip is widely available in modern browsers (Chrome 90+, Firefox 81+, Safari 16+). Deprecated / discouraged: overlay is a legacy alias for auto — do not use it in new code.

CSS Syntax

syntax.css
overflow-y: visible | hidden | clip | scroll | auto | initial | inherit;

Property Values

ValueDescriptionTry it
visibleDefault. Content may paint outside top and bottom edgesTry it
hiddenClips vertical overflow. No scrollbar UITry it
clipClips vertical overflow. Not a scroll container; no programmatic scrollTry it
scrollVertical scroll container; scrollbar track typically stays visibleTry it
autoVertical scrollbar appears only when content overflowsTry it
initialResets to the initial value, visibleTry it
inheritTakes the value from the parent elementTry it

How to Use overflow-y

Constrain height first, then choose how vertical overflow should behave.

  1. Give the element a limited height or max-height.
  2. Put content inside that is taller than that limit.
  3. Set overflow-y to auto, scroll, hidden, clip, or visible.
  4. Set overflow-x separately when horizontal behavior must differ, or use the overflow shorthand for both axes.
PieceRequired?Role
Height constraintYes (to overflow)Without a limit, the box grows and nothing overflows
Tall contentYes (to observe)More lines than the box height creates overflow
KeywordYesDecides paint outside, clip, or vertical scroll
overflow-xOftenA non-visible overflow-x can change how visible computes

Live Preview

A short box holds several lines. Change overflow-y and watch how the extra height behaves.

Height stays fixed. Only the vertical overflow keyword changes.

Box
Line 1 — this box is short. Line 2 — extra lines overflow. Line 3 — try each keyword. Line 4 — compare clip and scroll. Line 5 — auto shows a bar when needed.

overflow-y: auto

CSS Examples

Each snippet focuses on overflow-y. The fixed height is only there so content can overflow vertically. Use Try It Yourself for a live editor.

Example 1 — Scroll When Needed

Show a vertical scrollbar only if the text is taller than the box.

CSS
<style>
  div {
    height: 80px;
    overflow-y: auto;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<div>
  This box is short. Extra lines overflow, so auto adds a scrollbar when needed.
</div>
Try It Yourself

How It Works

  1. Limit the height. height: 80px stops the box from growing with the text.
  2. Put in more content. The paragraph is taller than 80px, so it overflows.
  3. Choose auto. overflow-y: auto clips the extra lines and shows a scrollbar only because it is needed.
  4. Scroll to read. The clipped lines stay reachable with vertical scroll.

Example 2 — Clip Without Scrollbars

Hide anything that sticks out on the top or bottom. No scrollbar appears.

CSS
<style>
  div {
    height: 80px;
    overflow-y: hidden;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<div>
  Extra text is clipped at the edge of this box. There is no scrollbar.
</div>
Try It Yourself

How It Works

  1. Keep the same fixed height. Overflow still needs a constrained box.
  2. Switch to hidden. overflow-y: hidden clips content at the padding box on the top and bottom.
  3. No scrollbar UI. Extra lines are cut off and not reachable by dragging a bar.
  4. Use for hard clips. Common for cards, menus, and panels where extra height must stay out of sight.

Example 3 — Always Vertically Scrollable

Force a vertical scroll container so the scrollbar track stays available.

CSS
<style>
  div {
    height: 80px;
    overflow-y: scroll;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<div>
  This box always acts as a scroll container. Scrollbars typically stay visible.
</div>
Try It Yourself

How It Works

  1. Set overflow-y to scroll. The element is always a vertical scroll container.
  2. Clip at the padding box. Extra height stays inside the scrollable area.
  3. Expect scrollbar UI. Many browsers reserve vertical scrollbar space even when content fits, which avoids layout jump.
  4. Prefer auto for most UI. Use scroll when you want the vertical track to stay stable.

Edge Cases & Pitfalls

If vertical overflow looks wrong, one of these is usually why.

height

No height limit, no overflow

Block boxes grow with content by default. Set a height or max-height before judging the keyword.

axes

visible can compute to auto

If overflow-x is hidden, scroll, or auto, a paired overflow-y: visible is computed as auto. Check both axes when results look unexpected.

hidden

hidden is not the same as clip

Both clip vertically. clip is not a scroll container and blocks programmatic scrolling. Prefer clip only when you want a hard non-scrolling clip.

a11y

Make scroll areas keyboard-reachable

Some browsers do not focus scrollable boxes by default. For important vertical scroll regions, consider tabindex="0", a landmark role, and an accessible name.

overlay

overlay is discouraged

Treat overlay as a deprecated legacy alias of auto. Use auto in new CSS.

Browser Support

overflow-y is a browser CSS property for vertical clipping and scrolling. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

overflow-y

Core values work in all modern browsers and Internet Explorer. overflow-y: clip needs Chrome 90+, Firefox 81+, Safari 16+, Edge 90+.

97% Core keyword support
Google Chrome All · clip 90+
Full support
Mozilla Firefox All · clip 81+
Full support
Apple Safari All · clip 16+
Full support
Microsoft Edge All · clip 90+
Full support
Opera Modern · clip 76+
Full support
Samsung Internet All · clip 15+
Full support
Internet Explorer 6+ · No clip
Partial
overflow-y Widely supported

Bottom line: Safe for visible, hidden, scroll, and auto everywhere you teach CSS. Use clip in modern browsers; fall back to hidden when needed. It is not a runtime API.

Key Takeaways

  • Role: control vertical overflow on the top and bottom edges only.
  • Initial value: visible. Constrain height or nothing overflows.
  • auto vs scroll: auto when needed; scroll to keep a stable vertical track.
  • Pair with overflow-x: a non-visible horizontal value can change how visible computes.

One line: constrain height first, then pick a keyword — without a height limit, vertical overflow never shows.

Frequently Asked Questions

It controls what happens when content is too tall for the element's padding box on the top and bottom edges: show it, clip it, or allow vertical scrolling.
The initial value is visible. Content can paint outside the box vertically, and the element is not a vertical scroll container by itself.
overflow is the shorthand for both axes. overflow-y sets only the vertical axis; overflow-x sets only the horizontal axis.
scroll typically keeps a vertical scrollbar track visible even when content fits. auto shows a vertical scrollbar only when content actually overflows.
If overflow-x is hidden, scroll, or auto, a paired overflow-y: visible is computed as auto. Browsers do not keep one axis fully visible while the other is a scroll/clip mode.
Core values are Baseline Widely available across modern browsers and Internet Explorer. overflow-y: clip needs Chrome 90+, Firefox 81+, or Safari 16+. It is a browser CSS property, not a Node.js feature.

Next: overscroll-behavior

Learn how to control scroll chaining when a scroll area reaches its edge.

overscroll-behavior tutorial →

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.

8 people found this page helpful