visible
Default behavior. Content can paint outside the box.
Overflow decides what happens when content is larger than its box. It can reveal, scroll, hide or clip content.
.activity-log {
max-height: 18rem;
overflow: auto;
}
Box Model
Content can outgrow its container because text is longer, images are wider, data tables are large or a fixed height is too small.
The overflow property lets you decide what happens next. Sometimes you need a scroll area. Sometimes you need to fix the layout instead.
The danger is using overflow: hidden to hide symptoms. If important content disappears, users lose information and controls.
Default behavior. Content can paint outside the box.
Clips overflowing content. Useful for decoration, risky for real text.
Adds scrollbars only when needed. Often best for panels and tables.
Clips without creating a scroll container. Useful for controlled visual clipping.
Visual model
Layout debugging becomes much easier when you can point to the exact part of the box that creates the visual result: inner space, outer space, edge, size or overflow behavior.
No special overflow behavior is needed.
The box must either grow, scroll or clip.
Do not hide important content by accident.
Examples
.activity-log {
max-height: 18rem;
overflow: auto;
padding: 1rem;
}
.pricing-card {
height: 14rem;
overflow: hidden;
/* important details may be clipped */
}
Rules that matter
Box model CSS should make the interface easier to reason about. When a value cannot be explained, it usually becomes a future layout bug.
Overflow often means content and dimensions disagree.
If users may need the content, let them scroll.
Hidden overflow can cut off outlines and menus.
Tiny scroll containers are painful to use.
Let content fit naturally until a limit is needed.
URLs, code and product names expose overflow bugs quickly.
Production thinking
Overflow handling decides whether real content remains usable when the design meets messy data.
Clipped focus rings, hidden text and nested scroll traps can make a page difficult for keyboard and screen magnifier users.
Overflow rules need real QA with long content, zoom, mobile widths and keyboard navigation.
Important content should not be visually hidden by accidental clipping.
Live code lab
The preview runs in an isolated iframe. Links and forms stay inside the practice area, so you can experiment without leaving the lesson.
Mini assignment
Practice assignment
Try it yourself
Self-check
Answer these questions before moving on. If the answer is vague, change the lab CSS and inspect the box again.
Senior audit upgrade
overflow: hidden can make a layout look fixed while hiding focusable content, long text or controls users still need.
clip clips without creating a scroll container; hidden clips and can still create overflow behavior.
Do not hide keyboard-focusable content outside a clipped area.
If content must scroll, make that scroll area obvious and usable.