The CSS <overflow> property controls what happens when an element’s content exceeds the defined width or height. It allows us to hide overflowing content, show scrollbars, or adapt automatically.
The <overflow> property can take four main values: visible (default, content overflows), hidden (overflowing content is hidden), scroll (scrollbars always appear), and auto (scrollbars appear only when necessary).
In the following example, the content would overflow the box, but the <overflow: hidden;> setting hides the excess:
Hidden, scroll, and auto provide different solutions for handling content. Scroll always shows a scrollbar, while auto only shows it when necessary.
With the <overflow-x> and <overflow-y> properties, we can control horizontal and vertical overflow separately. This is useful, for example, if we only want horizontal scrolling.
Overflow matters not only for block elements: inline-block elements can also handle overflow.
In Flexbox layouts, overflow ensures that oversized elements remain scrollable.
With text-overflow: ellipsis, long text is shortened with three dots (...) if it does not fit inside the box.
Correct use of overflow helps avoid unexpected layout problems and also improves content clarity:
Please sign in to ask Lara about CSS overflow.
Select Language
Set theme
© 2025 ReadyTools. All rights reserved.