Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
overflow property controls what happens: show it, hide it, add scrollbars, or clip it.You have a fixed-height card with dynamic content. What happens when the text is too long?
Content overflows and is visible outside the container. Can break layout!
overflow: visible;⚠️ Usually not desired - content spills out
Content is clipped - anything outside the box is hidden. No scrollbars.
overflow: hidden;⚠️ Content is lost - user can't see it
Scrollbars are always shown, even if content fits. Both axes get scrollbars.
overflow: scroll;ℹ️ Scrollbars always visible (can look odd)
Scrollbars appear only when needed. Most commonly used value.
overflow: auto;✅ Best choice - shows scrollbars only if needed
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="container">
<h1>📦 Overflow Property Demo</h1>
<div class="grid">
<div class="box">
<div class="label label-visible">overflow: visible</div>
<div class="content-box visible">
This is a lot of content that doesn't fit in the box.
Notice how it overflows and spills outside the container.
This can break your layout and overlap other elements.
Generally not recommended for production use.
</div>
<div class="note">Content spills out</div>
</div>
<div class="box">
<div class="label label-hidden">overflow: hidden</div>
<div class="content-box hidden">
This is a lot of content that doesn't fit in the box.
The overflow is hidden - you can't see the rest of the text.
No scrollbars appear. Content is simply clipped at the boundary.
</div>
<div class="note">Content is clipped</div>
</div>
<div class="box">
<div class="label label-scroll">overflow: scroll</div>
<div class="content-box scroll">
This is a lot of content that doesn't fit in the box.
Scrollbars are always shown on both axes, even if content fits.
You can scroll to see all the content.
</div>
<div class="note">Always has scrollbars</div>
</div>
<div class="box">
<div class="label label-auto">overflow: auto ⭐</div>
<div class="content-box auto">
This is a lot of content that doesn't fit in the box.
Scrollbars appear only when needed. This is the most commonly
used value because it's smart and doesn't add unnecessary scrollbars.
</div>
<div class="note">Smart scrollbars</div>
</div>
</div>
</div>
</body>
</html>Loading preview...
You can control horizontal and vertical overflow independently usingoverflow-x andoverflow-y.
Controls overflow on the X-axis (left/right)
overflow-x: auto;
overflow-y: hidden;Example: Horizontal scrolling tables
Controls overflow on the Y-axis (top/bottom)
overflow-x: hidden;
overflow-y: auto;Example: Scrollable chat windows
overflow-x: auto allows horizontal scrolling on mobile while preventing vertical scroll.