overflow controls content that is too big for its box.
| Value | Result |
|---|---|
visible |
content spills out (default) |
hidden |
extra content is cut off |
scroll |
scrollbars always shown |
auto |
scrollbars only when needed |
Use overflow-x and overflow-y for one direction only.
Text ellipsis
.title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
This shows ... when a single line of text is too long.
Example
Example — Overflow values
HTML
<style>
.box { width: 200px; height: 70px; border: 1px solid #333; margin-bottom: 12px; }
.hidden { overflow: hidden; }
.auto { overflow: auto; }
.ellipsis { width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
</style>
<div class="box hidden">overflow: hidden cuts this long text so that you cannot see the rest of it at all.</div>
<div class="box auto">overflow: auto adds a scrollbar when the text is longer than the box can hold.</div>
<p class="ellipsis">This very long single line of text ends with three dots</p>