background-clip - CSS | MDN

archived 9 Mar 2017 09:07:50 UTC

SummaryEdit

The background-clip CSS property specifies whether an element's background, either the color or image, extends underneath its border.
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

SyntaxEdit

/* 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;

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 (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

How to read CSS syntax.
<box>#
where
<box> = border-box | padding-box | content-box

ExamplesEdit

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

The yellow background extends behind the border.
The yellow background extends to the inside edge of the border.
The yellow background extends only to the edge of the content box.

SpecificationsEdit

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

Browser compatibilityEdit

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Feature Chrome Edge Firefox Internet Explorer Opera Safari Servo
Basic Support1.01124.029.0310.53.01?
content-box1.0124.029.0310.53.0?
text(Yes)4No support49.05No support(Yes)4(Yes)4?
Feature Android Chrome for Android Edge Mobile Firefox for Android IE Mobile Opera Mobile Safari Mobile
Basic Support4.1(Yes)(Yes)14.07.112.1(Yes)
content-box4.1(Yes)(Yes)14.07.112.1(Yes)
text??(Yes)49.05No support(Yes)4(Yes)4
1. Webkit also supports the prefixed version of this property, and in that case, in addition to the current keywords, the alternative synonyms are: padding, border, and content.
2. Gecko supported, from version 1.1 to version 1.9.2, which corresponds to Firefox 1.0 to 3.6 included, a different and prefixed syntax: -moz-background-clip: padding | border.
3. In IE 7 and IE 9 of Internet Explorer, it always behaved like background-clip: padding if overflow: hidden | auto | scroll
4. Support the prefixed version of the property only; according to the official blog, WebKit does not include text decorations or shadows in the clipping.
5. In Firefox 48, it was not activated by default and its support could be activated by setting layout.css.background-clip-text.enabled pref to true.

See alsoEdit

Thanks! Please check your inbox to confirm your subscription.

If you haven’t previously confirmed a subscription to a Mozilla-related newsletter you may have to do so. Please check your inbox or your spam filter for an email from us.
See also
  1. CSS
  2. CSS Reference
  3. CSS Background and Borders
  4. Guides
    1. Border-image generator
    2. Border-radius generator
    3. Scaling background images
    4. Using CSS multiple backgrounds
  5. Properties
    1. background
    2. background-attachment
    3. background-clip
    4. background-color
    5. background-image
    6. background-origin
    7. background-position
    8. background-position-x
    9. background-position-y
    10. background-repeat
    11. background-size
    12. border
    13. border-bottom
    14. border-bottom-color
    15. border-bottom-left-radius
    16. border-bottom-right-radius
    17. border-bottom-style
    18. border-bottom-width
    19. border-color
    20. border-image
    21. border-image-outset
    22. border-image-repeat
    23. border-image-slice
    24. border-image-source
    25. border-image-width
    26. border-left
    27. border-left-color
    28. border-left-style
    29. border-left-width
    30. border-radius
    31. border-right
    32. border-right-color
    33. border-right-style
    34. border-right-width
    35. border-style
    36. border-top
    37. border-top-color
    38. border-top-left-radius
    39. border-top-right-radius
    40. border-top-style
    41. border-top-width
    42. border-width
0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%