Overflow
Decides what happens to content that does not fit its element. Check out the MDN for how to use. overflow-x and overflow-y set one axis each, and overflow is the shorthand for both — one value sets them together, two set x then y.
.row { display: flex; gap: 6px; margin-bottom: 12px; } button { padding: 4px 10px; background-color: #d8dde3; border-radius: 4px; } button.on { background-color: coral; color: white; } .box { width: 200px; height: 120px; background-color: #eef1f4; } .tall { width: 300px; height: 300px; background-image: linear-gradient(135deg, coral, deepskyblue); }
Values
visible(default) — content is drawn past the element’s bounds.hidden— content is clipped to the element, following itsborder-radius.clip— read ashidden.scroll— the element scrolls.auto— read asscroll.
Notes
- Clipping is not per-axis. It is a rect mask, which clips both directions — so
overflow-x: hiddenon a plain element clips the vertical overflow too. The web’s “one axis clipped, the other scrolling” is only available on a<scroll>, below. - On a
<scroll>, hiding one axis is how you ask it to scroll in the other direction only:overflow-x: hiddenleaves a vertical scroll view,overflow-y: hiddena horizontal one. Hiding both, or hiding neither, scrolls both ways. - Layout sees one overflow for both axes, since that is all Yoga has, and it is the strongest of the three declarations:
scrollon either axis beatshidden, which beatsvisible. - Scrollbars are drawn over the content.
scrollbar-gutter: stablereserves room for them instead, andscrollbar-colorandscrollbar-widthstyle them — see<scroll>for those and for the::scrollbarpseudo-elements.