Menu

When to use overflow: clip with overflow-clip-margin (and when not to)
📰

When to use overflow: clip with overflow-clip-margin (and when not to)

DEV Community: css·Chris Rodriguez·15 days ago
#u4N0quKk
#devtocss#devto#dev#eee#clip
Reading 0:00
15s threshold

Goal

Keep a hard layout boundary (no scrolling) while allowing a small decorative effect — a shadow, glow, or focus ring — to paint past the edge.

What to use

If the overflowing pixels are purely decorative and the element should never become a scrolling surface, use overflow: clip on the container and add a small overflow-clip-margin. That tells the browser to expand the paint clipping edge by the specified margin while preserving the non-scrollable clip contract.

Expected behavior

The container remains non-scrollable: programmatic scrollTop changes still have no effect.

Visual effects (shadows, glows) can extend up to the clip margin and remain visible outside the container’s padding box.

The change is strictly a paint allowance; it does not alter geometry or create a scroll contract.

When not to use it

Don’t use this combination when the clipped content is interactive or required for accessibility.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.