Course contentsShow
← Web Development
Lesson 250 of 2,9824. CSS Layout FoundationsFree lesson

overflow: clip and overflow-clip-margin

Use modern overflow: clip for hard-edge clipping without scroll affordances.

overflow: clip and overflow-clip-margin

You'll learn how to create hard-edge clipping on overflowing content without scroll affordances.

When you've been using overflow: hidden, you might have noticed it sometimes creates a scrolling container in certain situations (like when you use position tricks inside). The modern overflow: clip value solves this cleanly.

What is overflow: clip?

Think of overflow: clip as a strict version of overflow: hidden. It clips overflowing content at the box's edge with absolutely no possibility of scrolling—programmatically or otherwise. It's like using scissors to cut off exactly what doesn't fit, with no exceptions.

Unlike hidden, which can still allow scrolling via JavaScript, clip means no scrolling, ever. The content is simply cut off at the boundary.

.container {
  width: 200px;
  height: 150px;
  overflow: clip;
}

The overflow-clip-margin Property

Here's where it gets interesting: overflow-clip-margin lets you extend the clipping region slightly beyond the box's padding edge. It's like saying "clip the content, but give it a little breathing room first."

.container {
  width: 200px;
  height: 150px;
  overflow: clip;
  overflow-clip-margin: 10px;
}

This clips content 10 pixels outside the container's normal boundary, rather than exactly at the edge. Useful when you want some overflow but still need that hard clip behavior.

Note: overflow-clip-margin only works with overflow: clip, not with other overflow values.

Key Takeaway: Use overflow: clip for strict, non-scrollable clipping at the box boundary, and combine it with overflow-clip-margin to control exactly where that clipping edge sits.