CSS background-clip Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Backgrounds & Effects

What You’ll Learn

The background-clip property controls how far a background color or image extends inside an element. It helps you clip backgrounds to the border, padding, content, or even the text itself.

01

Clipping Areas

Border, padding, content.

02

Syntax

Use clip keywords.

03

border-box

Default full-area paint.

04

content-box

Tightest background clip.

05

text

Gradient text effects.

06

background-origin

Related positioning property.

Definition and Usage

The background-clip CSS property defines how far a background should extend within an element. It controls whether the background is painted under the border, inside the padding, only behind the content, or clipped to the shape of the text.

This is especially useful when an element has visible padding or borders and you want the background to stop before those areas. It is also the property behind many modern gradient text effects.

💡
Beginner Tip

To see clipping clearly, give the element a thick border, visible padding, and a bright gradient background. Then switch between border-box, padding-box, and content-box.

📝 Syntax

Apply background-clip to any element that has a background color or background image:

syntax.css
selector {

  background-clip: <box>;

}

Basic Example

background-clip.css
.box {

  background-color: lightblue;

  padding: 20px;

  border: 5px solid darkblue;

  background-clip: content-box;

}

Syntax Rules

  • The initial value is border-box.
  • Use content-box when you want the background only behind the content area.
  • Use padding-box when the border should stay empty but padding should be filled.
  • For gradient text, combine background-clip: text with color: transparent.
  • Add -webkit-background-clip: text for better Safari support on text clipping.

⚡ Quick Reference

QuestionAnswer
Initial valueborder-box
Applies toBackground painting of an element
InheritedNo
AnimatableNo
Common useInset backgrounds, gradient text, bordered cards

Default Value

The initial value of background-clip is border-box. That means the background extends to the outer edge of the border, although it is painted underneath the border itself.

💎 Property Values

These are the main background-clip keywords beginners use most often.

ValueExampleMeaning
border-boxbackground-clip: border-box;Background extends to the outer edge of the border
padding-boxbackground-clip: padding-box;Background stops at the padding edge; border area stays empty
content-boxbackground-clip: content-box;Background is clipped to the content box only
textbackground-clip: text;Background is clipped to the foreground text shape
border-box

The default. Background fills the border area too, although the border paints on top.

Most common default behavior.

padding-box

Background fills padding and content, but not the border area.

Useful for framed cards.

content-box

Background appears only behind the content itself.

Creates an inset background look.

text

Clips the background to text shapes for gradient lettering.

Pair with color: transparent.

background-clip vs background-origin

PropertyControlsBest for
background-clipWhere the background is painted and clippedInset backgrounds, gradient text, bordered panels
background-originWhere the background positioning area startsAligning background images from border, padding, or content edge

👀 Live Preview

These panels use the same gradient, border, and padding. Only the clipping value changes:

border-box
padding-box
content-box

The heading above uses background-clip: text with color: transparent.

Examples Gallery

Try background-clip with content-box, padding-box, gradient text, and a side-by-side value comparison.

📚 Box Clipping

Use box keywords to control how far a background extends inside bordered elements.

Example 1 — content-box Background

Restrict the background to the content area so padding and border stay uncolored.

content-box-clip.css
.box {

  background-color: lightblue;

  background-image: linear-gradient(135deg, #38bdf8, #2563eb);

  padding: 20px;

  border: 5px solid #1e3a8a;

  background-clip: content-box;

}
Try It Yourself

How It Works

The gradient appears only behind the text content. Padding and border areas remain empty, creating an inset look.

Example 2 — padding-box vs border-box

Compare the default border-box behavior with padding-box to see how the border area changes.

padding-box-clip.css
.panel {

  background-image: linear-gradient(135deg, #fbbf24, #f97316);

  padding: 1rem;

  border: 8px solid #334155;

  background-clip: padding-box;

}
Try It Yourself

How It Works

With padding-box, the background no longer fills the border area. That makes the border look like a clean frame around the colored panel.

🎨 Text Effects

Use the text value to clip backgrounds to letter shapes.

Example 3 — Gradient Text with text

Create colorful headings by clipping a gradient background to text.

text-clip.css
.title {

  background-image: linear-gradient(135deg, #38bdf8, #a855f7, #f472b6);

  background-clip: text;

  -webkit-background-clip: text;

  color: transparent;

}
Try It Yourself

How It Works

The gradient is painted behind the text, then clipped to the letter shapes. Setting color: transparent lets the gradient show through.

Example 4 — Compare All Clip Values

Use the same gradient and border settings with different clip values to compare the results quickly.

clip-compare.css
.border-box { background-clip: border-box; }

.padding-box { background-clip: padding-box; }

.content-box { background-clip: content-box; }

.text { background-clip: text; color: transparent; }
Try It Yourself

How It Works

The same background looks very different depending on which clipping box you choose.

🧠 How background-clip Works

1

You add a background

Set a background-color or background-image on the element.

Background
2

You choose a clip box

Pick border-box, padding-box, content-box, or text.

Clip rule
3

The browser trims the paint area

Anything outside the chosen box is not painted, even if padding or border still exists.

Rendering
=

Precise background control

You can inset backgrounds, frame content with empty borders, or create gradient text.

Universal Browser Support

background-clip is supported in all modern browsers. The text value works best when you also include -webkit-background-clip: text.

Baseline · Modern browsers

Clip backgrounds reliably in today’s browsers

Chrome, Firefox, Safari, Edge, and Opera support the standard box keywords and text clipping.

97% Modern browser support
Google Chrome4+ · Desktop & Mobile
Full support
Mozilla Firefox4+ · Desktop & Mobile
Full support
Apple Safari5+ · macOS & iOS
Full support
Microsoft Edge12+ · Modern versions
Full support
Opera15+ · Modern versions
Full support

Fallback behavior

In unsupported browsers, backgrounds still render using the default border-box clipping.

💻
Internet Explorer Limited support · Use prefixed text clipping carefully
Partial
background-clip property 97% supported

Bottom line: Use background-clip confidently in modern projects, and include the WebKit prefix for gradient text when needed.

Conclusion

The background-clip property gives you precise control over where backgrounds appear inside an element. Whether you want an inset panel, a framed card, or gradient text, clipping helps you shape the background exactly where you need it.

Start with content-box and padding-box on bordered elements, then explore background-clip: text for colorful headings.

💡 Best Practices

✅ Do

  • Use thick borders and padding when teaching or testing clip values
  • Pair background-clip: text with color: transparent
  • Add -webkit-background-clip: text for Safari gradient text
  • Compare box values side by side before choosing one
  • Keep text readable when using gradient text effects

❌ Don’t

  • Expect visible clipping without padding or borders on box demos
  • Forget that border-box is the default
  • Confuse background-clip with background-origin
  • Use gradient text for long paragraphs
  • Remove focus styles just because text looks decorative

Key Takeaways

Knowledge Unlocked

Five things to remember about background-clip

Use these points when shaping backgrounds inside elements.

5
Core concepts
📦02

Box Keywords

border, padding, content.

Values
📝03

text Value

Creates gradient lettering.

Effect
04

border-box Default

Full-area background paint.

Default
🛠05

Not origin

Clip trims paint, not position.

Compare

❓ Frequently Asked Questions

The background-clip property controls how far a background color or background image extends inside an element. It can clip the background to the border, padding, content, or text area.
The initial value is border-box, which means the background extends to the outer edge of the border, although it is painted underneath the border itself.
padding-box includes the padding area in the painted background. content-box clips the background tighter so it appears only behind the content itself.
Set a background-image gradient, use background-clip: text, add -webkit-background-clip: text for Safari, and set color: transparent so the gradient shows through the letter shapes.
background-origin decides where the background positioning area starts. background-clip decides where the background is actually painted and clipped.

Practice in the Live Editor

Open the HTML editor, add borders and gradients, and experiment with background-clip instantly.

HTML Editor →

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