CSS Reference ยท Box Model and Sizing
The overflow-clip-margin property
Reference for the CSS overflow-clip-margin property: how far content may paint outside a box that uses overflow: clip. Syntax, values, example and browser support.
The overflow-clip-margin property sets how far content may paint beyond the edge of a box before it is clipped. It only takes effect where the clipping comes from overflow: clip (or overflow-x: clip / overflow-y: clip). It is handy when you want to clip content but still let a focus ring or a shadow show a little.
.card { overflow: clip; overflow-clip-margin: 12px; }
Try it
In a supporting browser, the orange stripes in the second frame extend 20px past the border before being cut. Where the property is not supported, both frames look the same.
Syntax
overflow-clip-margin: <visual-box> || <length [0,โ]> /* visual-box: content-box | padding-box | border-box */
- Initial value:
0px - Applies to: elements to which
overflow: clipapplies - Inherited: no
- Animatable: yes, as a length
- Computed value: as specified, with the length made absolute
Values
| Value | Description |
|---|---|
<length> |
The extra distance, measured from the chosen box edge, up to which content stays visible. Must not be negative. |
content-box |
Measure from the content edge. |
padding-box |
Measure from the padding edge. This is the default reference box. |
border-box |
Measure from the border edge. |
Usage notes
- Only for
overflow: clip. Onhidden,scrollandautothe property has no effect, because those create a scroll container whose clip cannot be moved. - Replaced elements. For elements such as
<img>or<video>, a box keyword such ascontent-boxcan control which edge the clip uses. - Use cases. Letting a slightly oversized focus outline, an offset shadow or a hover scale-up show while still preventing a large child from escaping.
- Fallback. Browsers without support clip at the plain edge, so design so the content still reads correctly without the extra margin.
Browser support
Limited: it is supported in Chromium-based browsers, but not yet across all major browsers, so check current support tables before relying on it.
Related
overflowoverflow-yclip-path- Lesson: Overflow