The background-clip CSS property specifies whether an element's background, either the color or image, extends underneath its border.

/* Keyword values */
background-clip: border-box;
background-clip: padding-box;
background-clip: content-box;
background-clip: text;

/* Global values */
background-clip: inherit;
background-clip: initial;
background-clip: unset;

If no background image or color is set, this property will only have a visual effect when the border has transparent regions or partially opaque regions (due to border-style or border-image); otherwise the border covers up the difference.

Initial valueborder-box
Applies toall elements. It also applies to ::first-letter and ::first-line.
Inheritedno
Mediavisual
Computed valueas specified
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

Values

border-box
The background extends to the outside edge of the border (but underneath the border in z-ordering).
padding-box
No background is drawn below the border. (The background extends to the outside edge of the padding.)
content-box
The background is painted within (clipped to) the content box.
text
The background is painted within (clipped to) the foreground text.

Formal syntax

<box>#

where
<box> = border-box | padding-box | content-box

Examples

Note: You can find an example of -webkit-background-clip: text usage in our Learning Area.

HTML content

<p class="border-box">The yellow background extends behind the border.</p>
<p class="padding-box">The yellow background extends to the inside edge of the border.</p>
<p class="content-box">The yellow background extends only to the edge of the content box.</p>

CSS content

p {
   border: 10px navy;
   border-style: dotted double;
   margin: 1em;
   padding: 2em;
   background: #F8D575;
}
.border-box { background-clip: border-box; }
.padding-box { background-clip: padding-box; }
.content-box { background-clip: content-box; }

Output

Specifications

Specification Status Comment
CSS Backgrounds and Borders Module Level 3
The definition of 'background-clip' in that specification.
Candidate Recommendation Initial definition
CSS Backgrounds and Borders Module Level 4
The definition of 'background-clip' in that specification.
Editor's Draft Add text value

Browser compatibility

No compatibility data found. Please contribute data for "background-clip" to the MDN compatibility data repository.

See also