CSS overflow-clip-margin Property

The CSS overflow-clip-margin property controls how far an element's overflow clipping edge extends beyond its specified box edge.

It is designed for use with overflow: clip, allowing a limited amount of overflowing content to remain visible without enabling scrolling. This is useful for preserving shadows, outlines, and other visual effects near the edges of clipped elements.

overflow-clip-margin Syntax

The property accepts a non-negative length and an optional box edge keyword. The length specifies how far the clipping edge extends beyond the selected box edge.

Basic Syntax

selector {
  overflow-clip-margin: 10px;
}

Length Values

.box {
  overflow-clip-margin: 0;
}
.box {
  overflow-clip-margin: 8px;
}
.box {
  overflow-clip-margin: 1rem;
}
.box {
  overflow-clip-margin: 0.5em;
}

Box Edge Values

.box {
  overflow-clip-margin: padding-box 10px;
}
.box {
  overflow-clip-margin: border-box 10px;
}
.box {
  overflow-clip-margin: content-box 10px;
}

The box edge keyword and length may appear in either order.

CSS-Wide Keywords

.box {
  overflow-clip-margin: initial;
}
.box {
  overflow-clip-margin: inherit;
}
.box {
  overflow-clip-margin: unset;
}
.box {
  overflow-clip-margin: revert;
}
.box {
  overflow-clip-margin: revert-layer;
}

The initial value is 0px, measured from the border box edge. When the property is omitted, no additional clipping margin is requested.

Property Values

Value Description
<length> Specifies a non-negative distance beyond the selected box edge.
content-box Measures the clipping margin from the content box edge.
padding-box Measures the clipping margin from the padding box edge.
border-box Measures the clipping margin from the border box edge.
initial Resets the property to its initial value.
inherit Uses the computed value of the parent element.
unset Resets the property to its initial value because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value 0px from the border box edge
Inherited No
Applies to Elements to which overflow applies
Computed value Specified box edge and computed length
Animation type Length component by computed value type
Percentage values Not accepted
Negative values Not accepted
Affects layout dimensions No

Valid Values

.box {
  overflow-clip-margin: 0;
}
.box {
  overflow-clip-margin: 12px;
}
.box {
  overflow-clip-margin: 1rem;
}
.box {
  overflow-clip-margin: padding-box 8px;
}
.box {
  overflow-clip-margin: 8px border-box;
}

Invalid Values

.box {
  overflow-clip-margin: -10px;
}
.box {
  overflow-clip-margin: 20%;
}
.box {
  overflow-clip-margin: auto;
}
.box {
  overflow-clip-margin: 10px 20px;
}

Negative lengths, percentages, auto, and multiple length values are not valid.

How It Works

Normally, overflow: clip clips content at the overflow clip edge. The overflow-clip-margin property moves that edge outward by the specified distance.

Without a Clipping Margin

.box {
  overflow: clip;
  overflow-clip-margin: 0;
}

Overflowing content is clipped at the default overflow clip edge.

With a Clipping Margin

.box {
  overflow: clip;
  overflow-clip-margin: 15px;
}

Content may remain visible up to 15 pixels beyond the border box edge before clipping occurs.

Increasing the Margin

.box {
  overflow: clip;
  overflow-clip-margin: 30px;
}

A larger margin provides more space for overflowing content to remain visible.

Important Consideration

The property changes the clipping boundary, not the element's actual dimensions or position. It does not add padding or margins to the layout.

Understanding the Overflow Clip Edge

The overflow clip edge defines the boundary beyond which overflowing content is not painted.

Default Clipping Edge

.box {
  overflow: clip;
  overflow-clip-margin: 0;
}

With the default border box reference, the clipping edge is at the border box boundary.

Extended Clipping Edge

.box {
  overflow: clip;
  overflow-clip-margin: 12px;
}

The clipping edge extends 12 pixels beyond the border box boundary.

Clipping vs. Layout

Extending the clipping edge does not change the space occupied by the element. Surrounding elements are positioned according to normal layout rules.

Clipping vs. Scrolling

Unlike overflow: auto or overflow: scroll, overflow: clip does not create a scroll container or permit programmatic scrolling through the clipped content.

Length Values

The clipping margin can use supported CSS length units, including pixels, rems, ems, and viewport-relative units.

Pixels

.box {
  overflow: clip;
  overflow-clip-margin: 10px;
}

Root-Relative Units

.box {
  overflow: clip;
  overflow-clip-margin: 1rem;
}

Font-Relative Units

.box {
  overflow: clip;
  overflow-clip-margin: 0.75em;
}

Viewport Units

.box {
  overflow: clip;
  overflow-clip-margin: 2vw;
}

Calculated Lengths

.box {
  overflow: clip;
  overflow-clip-margin: calc(0.5rem + 4px);
}

Important Consideration

Only non-negative lengths are valid. Percentage values are not supported by this property.

Box Edge Values

The property can specify which box edge serves as the reference point for the clipping margin.

content-box

.box {
  padding: 20px;
  border: 4px solid #64748b;
  overflow: clip;
  overflow-clip-margin: content-box 10px;
}

The clipping edge is positioned 10 pixels beyond the content box edge.

padding-box

.box {
  padding: 20px;
  border: 4px solid #64748b;
  overflow: clip;
  overflow-clip-margin: padding-box 10px;
}

The clipping edge is positioned 10 pixels beyond the padding box edge.

border-box

.box {
  padding: 20px;
  border: 4px solid #64748b;
  overflow: clip;
  overflow-clip-margin: border-box 10px;
}

The clipping edge is positioned 10 pixels beyond the border box edge.

Comparison

Box Edge Reference Boundary
content-box Outer edge of the content area
padding-box Outer edge of the padding area
border-box Outer edge of the border area

Important Consideration

The box edge syntax is defined in the specification, but browser implementations may support only the length portion. Test compatibility before relying on a particular box edge keyword.

Using overflow: clip

The most common use of overflow-clip-margin is with overflow: clip.

Basic Example

.card {
  overflow: clip;
  overflow-clip-margin: 12px;
}

Clipping a Decorative Element

.card {
  position: relative;
  overflow: clip;
  overflow-clip-margin: 16px;
}
.card::after {
  content: "";
  position: absolute;
  width: 40px;
  height: 40px;
  right: -10px;
  bottom: -10px;
  background-color: #2563eb;
}

The clipping margin allows part of the decorative pseudo-element to remain visible beyond the card's border box.

Important Consideration

Using overflow: hidden instead of overflow: clip does not provide the same clipping-margin behavior. The property is intended for the clip overflow mode.

Shadows and Outlines

One practical use for overflow-clip-margin is preserving visual effects that extend beyond an element's normal boundaries.

Box Shadows

.card {
  overflow: clip;
  overflow-clip-margin: 20px;
}
.card-content {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

The additional clipping margin can allow more of the child element's shadow to remain visible.

Focus Outlines

.panel {
  overflow: clip;
  overflow-clip-margin: 8px;
}
.panel button:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

The extended clipping edge may help prevent focus outlines near the panel boundary from being cut off.

Decorative Transforms

.panel {
  overflow: clip;
  overflow-clip-margin: 15px;
}
.panel .decoration {
  transform: translateX(10px);
}

The decoration can extend slightly beyond the panel before being clipped.

Important Consideration

The clipping margin does not guarantee that every visual effect will remain visible. Ancestor clipping, stacking contexts, and other layout conditions can still restrict painting.

clip vs. hidden

The clip and hidden overflow values both conceal overflowing content, but they have different scrolling behavior.

Behavior overflow: clip overflow: hidden
Clips overflowing content Yes Yes
Creates a scroll container No Yes
Allows programmatic scrolling No Yes
Uses overflow-clip-margin Yes No

Using clip

.box {
  overflow: clip;
  overflow-clip-margin: 10px;
}

Using hidden

.box {
  overflow: hidden;
  overflow-clip-margin: 10px;
}

In the second example, the clipping margin does not extend the clipping edge created by overflow: hidden.

overflow-clip-margin Example

This example compares three clipping margins. Each container has the same dimensions and an absolutely positioned child that extends beyond its border box.

HTML Example

<div class="clip-demo">
  <div class="clip-item">
    <h3>0px</h3>
    <div class="clip-box clip-zero">
      <span class="clip-shape"></span>
    </div>
  </div>
  <div class="clip-item">
    <h3>10px</h3>
    <div class="clip-box clip-ten">
      <span class="clip-shape"></span>
    </div>
  </div>
  <div class="clip-item">
    <h3>25px</h3>
    <div class="clip-box clip-twentyfive">
      <span class="clip-shape"></span>
    </div>
  </div>
</div>

CSS Example

.clip-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 45px;
  padding: 25px;
}
.clip-item h3 {
  font-size: 16px;
  margin-bottom: 12px;
}
.clip-box {
  position: relative;
  width: 120px;
  height: 90px;
  border: 2px solid #64748b;
  background-color: #dbeafe;
  overflow: clip;
}
.clip-shape {
  position: absolute;
  right: -20px;
  bottom: -20px;
  width: 55px;
  height: 55px;
  background-color: #2563eb;
}
.clip-zero {
  overflow-clip-margin: 0;
}
.clip-ten {
  overflow-clip-margin: 10px;
}
.clip-twentyfive {
  overflow-clip-margin: 25px;
}
Browser Result

0px

10px

25px

The first container clips the blue shape at its border box. The second allows 10 pixels of additional overflow, and the third allows 25 pixels. The shape itself does not move or change size.

Using a Box Shadow

The following example shows how a clipping margin can preserve a shadow extending beyond a child element.

<div class="shadow-clip-demo">
  <div class="shadow-clip-box">
    <div class="shadow-clip-card">Card with Shadow</div>
  </div>
</div>
.shadow-clip-box {
  width: 240px;
  padding: 15px;
  overflow: clip;
  overflow-clip-margin: 15px;
  background-color: #f1f5f9;
}
.shadow-clip-card {
  padding: 20px;
  background-color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
Browser Result
Card with Shadow

The additional clipping margin allows the shadow to extend farther beyond the container's border box without creating a scrollable region.

Accessibility Considerations

Clipping should be used carefully because it can conceal information or visual indicators needed by users.

Preserve Focus Indicators

Focus outlines may extend beyond an element's boundaries. A clipping margin can help preserve them when a surrounding container uses overflow: clip.

.panel {
  overflow: clip;
  overflow-clip-margin: 8px;
}
.panel button:focus-visible {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

Avoid Hiding Interactive Content

Do not place essential buttons, links, or form controls outside a clipping boundary unless they remain accessible through the intended interface.

Support Browser Zoom

Test clipped layouts at increased zoom levels. Larger text and controls may extend beyond their original boundaries.

Important Consideration

The clipping margin only changes the painted clipping boundary. It does not provide scrolling or another way to reach content that remains clipped.

Common Mistakes

Using the Property Without overflow: clip

.box {
  overflow: hidden;
  overflow-clip-margin: 10px;
}

The clipping margin does not extend the clipping edge created by overflow: hidden.

Using Negative Lengths

.box {
  overflow-clip-margin: -10px;
}

Negative values are invalid.

Using Percentages

.box {
  overflow-clip-margin: 10%;
}

The property accepts lengths, not percentages.

Using Multiple Lengths

.box {
  overflow-clip-margin: 10px 20px;
}

The property does not use the one-to-four-value syntax of margin or padding.

Expecting Layout Space to Increase

The clipping margin does not change the element's box dimensions or push neighboring elements away.

Assuming All Box Edge Keywords Are Supported

Browser implementations may not support the optional content-box, padding-box, and border-box syntax consistently.

Ignoring Ancestor Clipping

An ancestor with restrictive overflow settings may still clip content even when a child has an extended overflow clip edge.

Expecting Scrolling

overflow: clip does not provide scrolling. Increasing the clipping margin does not change that behavior.

Important Considerations

Keep the following points in mind when using overflow-clip-margin:

  • The property controls the distance between a selected box edge and the overflow clip edge.
  • It is intended for use with overflow: clip.
  • Its initial value is 0px from the border box edge.
  • The property is not inherited.
  • It accepts non-negative CSS length values.
  • Percentages and negative values are invalid.
  • It does not accept multiple length values.
  • The optional box edge keywords are content-box, padding-box, and border-box.
  • Support for box edge keywords may vary between browsers.
  • The clipping margin extends the painted clipping boundary.
  • It does not change the element's layout dimensions.
  • It does not create a scroll container.
  • It does not enable programmatic scrolling through clipped content.
  • It can help preserve shadows, outlines, and decorative effects.
  • Other clipping boundaries may still restrict visible content.
  • Large clipping margins may allow content to overlap nearby elements visually.
  • Clipping should not conceal essential interactive content.
  • Browser support is not universal.
  • Test the property in browsers and layouts where it is required.

Browser Support

The CSS overflow-clip-margin property has Limited availability and is not supported consistently across all major browsers.

Support for a simple length value is more widely implemented than support for the optional box edge keywords. Browsers that do not recognize the property ignore the declaration.

When the property is unsupported, an element using overflow: clip continues to clip content at its normal overflow clip edge.

Fallback Example

.box {
  overflow: clip;
  overflow-clip-margin: 12px;
}

This remains a valid clipped container in browsers that support overflow: clip but do not support overflow-clip-margin. The extra clipping margin is simply not applied.

For current compatibility information, visit Can I Use? and search for overflow-clip-margin.

Specifications

The overflow-clip-margin property is defined in CSS Overflow Module Level 3.

CSS Overflow Module Level 3: overflow-clip-margin

The specification describes the overflow clip edge, the optional box edge reference, and the length used to extend the clipping boundary.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: overflow-clip-margin