The overflow property is a shorthand for overflow-x and overflow-y. It controls what happens when content does not fit inside an element’s padding box.
The initial value is visible: content can paint outside the box. Other keywords clip the content, add scrollbars, or both. One keyword sets both axes; two keywords set horizontal then vertical. The box must be size-constrained (for example with height) or there is nothing to overflow.
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.
Set overflow to auto, scroll, hidden, clip, or visible.
Use two values, or the overflow-x / overflow-y longhands, when axes must differ.
Piece
Required?
Role
Size constraint
Yes (to overflow)
Without a limit, the box grows and nothing overflows
Overflow keyword
Yes
Decides clip, scroll, or paint outside
One or two values
By design
Same on both axes, or horizontal then vertical
Keyboard access
For scroll areas
Scrollable regions may need focusability for keyboard users
Try it
Live Preview
A short fixed box holds long text. Change overflow and watch how the extra lines behave.
Width and height stay fixed. Only the overflow keyword changes.
Box
Overflow happens when content is taller than this box. Try each keyword and compare how the extra text is shown, clipped, or scrolled.
overflow: auto
Code
CSS Examples
Each snippet focuses on overflow. The fixed size is only there so content can overflow. Use Try It Yourself for a live editor.
Example 1 — Scroll When Needed
Show a scrollbar only if the text does not fit.
CSS
<style>
div {
width: 200px;
height: 80px;
overflow: auto;
border: 1px solid #cbd5e1;
padding: 8px;
}
</style>
<div>
This box is short. Extra lines overflow, so auto adds a scrollbar when needed.
</div>
This box is short. Extra lines overflow, so auto adds a scrollbar when needed. Keep scrolling to read the rest of the sample text inside the box.
How It Works
Limit the box.width and height stop the container from growing with the text.
Put in more content. The paragraph is taller than 80px, so it overflows.
Choose auto.overflow: auto clips the extra text and shows a scrollbar only because it is needed.
Scroll to read. The box becomes a scroll container so the clipped lines stay reachable.
Example 2 — Clip Without Scrollbars
Hide anything that does not fit. No scrollbar appears.
CSS
<style>
div {
width: 200px;
height: 80px;
overflow: hidden;
border: 1px solid #cbd5e1;
padding: 8px;
}
</style>
<div>
Extra text is clipped at the edge of this box. There is no scrollbar.
</div>
This box always acts as a scroll container. Scrollbars typically stay visible, even when content is short, depending on the browser and OS.
How It Works
Set overflow to scroll. The element is always a scroll container.
Clip at the padding box. Extra content stays inside the scrollable area.
Expect scrollbar UI. Many browsers reserve scrollbar space even when content fits, which avoids layout jump.
Prefer auto for most UI. Use scroll when you want the scrollbar track to stay stable.
Edge Cases & Pitfalls
If overflow looks wrong, one of these is usually why.
size
No size limit, no overflow
Block boxes grow with content by default. Set a height, max-height, or width constraint before judging the keyword.
hidden
hidden is not the same as clip
hidden can still create a scroll container and allow programmatic or keyboard scroll into view. clip does not. Prefer clip only when you want a hard non-scrolling clip.
axes
Mixed axes change visible / clip
If one axis is neither visible nor clip, a paired visible computes like auto, and a paired clip can compute like hidden. Check both axes when results look unexpected.
a11y
Make scroll areas keyboard-reachable
Some browsers do not focus scrollable boxes by default. For important 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 (and modern scrollbar properties such as scrollbar-gutter when you need gutter control).
Compatibility
Browser Support
overflow is a browser CSS property for clipping and scroll containers. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
overflow
Core values work in all modern browsers and Internet Explorer. overflow: clip needs Chrome 90+, Firefox 81+, Safari 16+, Edge 90+.
97%Core keyword support
Google ChromeAll · clip 90+
Full support
Mozilla FirefoxAll · clip 81+
Full support
Apple SafariAll · clip 16+
Full support
Microsoft EdgeAll · clip 90+
Full support
OperaModern · clip 76+
Full support
Samsung InternetAll · clip 15+
Full support
Internet Explorer6+ · No clip
Partial
overflowWidely 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.
Remember
Key Takeaways
Role: shorthand for how overflowing content is shown, clipped, or scrolled on both axes.
Initial value:visible. Constrain the box or nothing overflows.
auto vs scroll: auto when needed; scroll to keep a stable scroll container UI.
hidden vs clip: both clip; only clip blocks programmatic scrolling as a non-scroll container.
One line: constrain the box first, then pick a keyword — without a size limit, overflow never shows.
Frequently Asked Questions
It is a shorthand for overflow-x and overflow-y. It controls what happens when content is too large for the element's padding box: show it, clip it, or make the box scrollable.
The initial value is visible. Overflowing content can paint outside the box, and the element is not a scroll container.
scroll always makes a scroll container and typically shows scrollbars even when content fits. auto adds scrollbars only when content actually overflows.
Both clip overflowing content. hidden can still create a scroll container and allow programmatic or keyboard scrolling into view. clip does not create a scroll container and blocks programmatic scrolling.
The box must be constrained. Without a height, max-height, width, or similar limit, block boxes grow with their content and nothing overflows.
Core values are Baseline Widely available across modern browsers and Internet Explorer. overflow: clip needs Chrome 90+, Firefox 81+, or Safari 16+. It is a browser CSS property, not a Node.js feature.