Overflow
overflow decides what happens when content does not fit. visible (default) lets it spill out, hidden clips it, scroll always shows scrollbars and auto shows them only when needed. overflow-x and overflow-y control each axis.
text-overflow: ellipsis with white-space: nowrap and overflow: hidden truncates a single line with an ellipsis. Hiding overflow also contains floats and some margin collapse.
Example
<style>
.box { width: 220px; height: 70px; border: 2px solid #64748b; margin-bottom: 12px; padding: 4px; }
.auto { overflow: auto; }
.hidden { overflow: hidden; }
.trunc { width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
</style>
<div class="box auto">Scrolls when needed. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.</div>
<div class="box hidden">Clipped. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.</div>
<p class="trunc">This long sentence is cut off with an ellipsis at the end.</p>Exercise
Add scrollbars only when content overflows.
.panel { overflow: ; }
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.