CSS background-clip Property

Beginner
8 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The background-clip property sets how far a background-color or background-image may paint. Clip it to the border box, the padding box, the content box, the letters, or the border area.

A thick border and some padding make the three box keywords easy to compare. background-origin is different: it chooses where position and size are measured from, not where the paint stops.

Standard-track.

Not deprecated. border-box, padding-box, and content-box are Baseline. text is widely used; keep -webkit-background-clip: text for older engines. border-area is Limited availability (Chrome 150+, Safari 18.2+, not Firefox).

CSS Syntax

syntax.css
background-clip: border-box | padding-box | content-box | text | border-area | initial | inherit;

With several backgrounds, you can list one clip per layer, separated by commas, in the same order as background-image.

Property Values

The editors below use a dashed border and padding so you can see where the paint stops.

ValueDescriptionTry it
border-boxDefault. Paint reaches the outer border edge and sits under the borderTry it
padding-boxPaint stops at the outer padding edge. Nothing under the borderTry it
content-boxPaint only in the content box. Padding and border stay clearTry it
textPaint only inside the letters. Pair with transparent text colorTry it
border-areaPaint only where the border is drawn. Limited availabilityTry it
initialSets this property to its default value, border-boxTry it
inheritCopies the clip from the parent. The background layers themselves are not inheritedTry it

How to Use background-clip

Give the element a background, leave room with padding and a border, then choose which box keeps the paint.

  1. Set a background-color or background-image (a linear-gradient() counts).
  2. Add padding and a visible border so the three boxes differ. A dashed border makes border-box easy to spot.
  3. Set background-clip on that element. It is not inherited.
  4. For gradient text, also set -webkit-background-clip: text and color: transparent.
PieceRequired?Role
Background color or imageYesThe paint you are clipping
Border and/or paddingYes, for box keywordsCreates separate border, padding, and content areas
Transparent text colorFor textLets the clipped background show through the letters
KeywordYesborder-box, padding-box, content-box, text, or border-area

Live Preview

A dashed border, padding, and a blue gradient. Change background-clip and watch where the paint stops.

Dashed line = border. Space inside it = padding. The label sits in the content box.

Clip
Content area

background-clip: content-box

CSS Examples

Each snippet sets only the background, the space around it, and the clip keyword. Use Try It Yourself for a live editor.

Example 1 — Clip to the Content Box

Keep the gradient only behind the words. Padding and border stay clear.

CSS
<style>
  div {
    padding: 24px;
    border: 12px dashed #1e3a8a;
    background-image: linear-gradient(135deg, #38bdf8, #2563eb);
    background-clip: content-box;
  }
</style>

<div>Content area</div>
Try It Yourself

How It Works

  1. Draw the three boxes. The dashed line is the border. The space inside it is padding. The words sit in the content box.
  2. Paint a gradient. linear-gradient(135deg, #38bdf8, #2563eb) is a background-image.
  3. Cut at the content edge. background-clip: content-box keeps the gradient only behind the text. Padding and border show no fill.
  4. Compare with the default. Without this property the fill would reach under the dashes (border-box).

Example 2 — Clip to the Padding Box

Fill through the padding, but stop before the border.

CSS
<style>
  div {
    padding: 24px;
    border: 12px dashed #1e3a8a;
    background-image: linear-gradient(135deg, #38bdf8, #2563eb);
    background-clip: padding-box;
  }
</style>

<div>Content area</div>
Try It Yourself

How It Works

  1. Same border and padding. Only the clip keyword changes from Example 1.
  2. Include the padding. padding-box paints through the content and the padding.
  3. Leave the border empty. Gaps in the dashed border stay blank. No fill sits under the dashes.
  4. One step out from content. Border → padding → content is outside to inside. padding-box is the middle choice.

Example 3 — Gradient Text

Clip a gradient to the letters and make the text color transparent.

CSS
<style>
  h1 {
    font-size: 2rem;
    background-image: linear-gradient(90deg, #2563eb, #db2777);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }
</style>

<h1>Gradient text</h1>
Try It Yourself

How It Works

  1. Paint a gradient. The image sits behind the text first.
  2. Clip to the glyphs. background-clip: text keeps only the paint that falls inside the letters. Keep -webkit-background-clip: text for older WebKit and Chromium builds.
  3. Hide the ink. color: transparent removes the solid fill so the clipped gradient shows through.
  4. Keep contrast. If the gradient fails to load, transparent text disappears. Add a fallback background-color, and check contrast for readers with low vision. You can gate the effect with @supports.

Edge Cases & Pitfalls

If every keyword looks the same, one of these is usually why.

border

Opaque borders hide border-box

The background is always painted under the border. A solid opaque border covers that paint. Use a dashed border or a transparent border color to see border-box.

origin

Clip is not origin

background-origin sets the positioning area. Clip sets the paint cutoff. You can set them to different boxes on purpose.

text

Opaque text hides text

If color is solid, you mostly see the ink, not the clipped background. Use a transparent (or very translucent) text color.

root

No effect on the root element

On the document root, background-clip does nothing. Put canvas backgrounds on body instead.

shorthand

One box in the shorthand can set clip

In the background shorthand, a single box keyword can set both origin and clip. Two box keywords set origin then clip. Prefer the longhands while you learn.

Browser Support

background-clip is a browser painting property. Node.js, Deno, and Bun do not paint it. Versions below are for the classic box keywords unless noted.

✓ Baseline · Box values since 2015

background-clip

border-box / padding-box / content-box: Chrome 1+, Firefox 4+, Safari 3+, Edge 12+, Internet Explorer 9+, Opera 10.5+. text: keep -webkit- for older engines. border-area: Chrome 150+, Safari 18.2+.

96% Box keywords support
Google Chrome 1+ boxes · text unprefixed 120+
Full support
Mozilla Firefox 4+ boxes · text 49+
Full support
Apple Safari 3+ boxes · text 14+
Full support
Microsoft Edge 12+ boxes · text unprefixed 120+
Full support
Opera 10.5+ boxes
Full support
Samsung Internet Classic boxes supported
Full support
Internet Explorer 9+ boxes · No text
Partial
background-clip Widely supported

Bottom line: Safe for border-box, padding-box, and content-box in current browsers and Internet Explorer 9+. For text, also set -webkit-background-clip: text. border-area is Limited availability: Chrome 150+, Safari 18.2+, and not in Firefox.

Key Takeaways

  • Role: choose how far the background may paint — border, padding, content, text, or border area.
  • Default: border-box. Use a dashed or transparent border when you need to see paint under the border.
  • Not origin: origin places the image; clip cuts the paint.
  • Gradient text: background-clip: text, -webkit-background-clip: text, and a transparent text color.

One line: background-clip decides where the background stops — after you have a background, and usually after you have padding or a border to compare.

Frequently Asked Questions

It sets how far a background color or image is allowed to paint: under the border, only through the padding, only in the content box, only inside the letters, or only in the border area.
border-box. The background reaches the outer border edge and sits behind the border. With a solid opaque border you may not notice that paint under the border.
background-origin chooses the box used for background-position and background-size. background-clip chooses where the paint is cut off. They share keywords but do different jobs.
Set a background-image gradient, then background-clip: text and -webkit-background-clip: text. Make the text transparent with color: transparent so the gradient shows through the letters.
The background is always painted under the border. A solid opaque border hides that area. Use a dashed border, a gap, or a transparent border color to see border-box.
border-box, padding-box, and content-box are Baseline: Chrome 1+, Firefox 4+, Safari 3+, Edge 12+, Internet Explorer 9+. text is widely used; keep -webkit-background-clip: text for older engines. border-area needs Chrome 150+ or Safari 18.2+ and is missing in Firefox. It is a browser CSS property, not a Node.js feature.

Next: background-color

Learn the solid color that sits under every background image.

background-color tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful