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 value | border-box |
---|---|
Applies to | all elements. It also applies to ::first-letter and ::first-line . |
Inherited | no |
Media | visual |
Computed value | as specified |
Animation type | discrete |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
/* 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;
border-box
padding-box
content-box
text
<box>#where
<box> = border-box | padding-box | content-box
Note: You can find an example of -webkit-background-clip: text usage in our Learning Area.
<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>
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; }
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 |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | Servo |
---|---|---|---|---|---|---|---|
Basic Support | 1.01 | 12 | 4.02 | 9.03 | 10.5 | 3.01 | ? |
content-box | 1.0 | 12 | 4.02 | 9.03 | 10.5 | 3.0 | ? |
text | (Yes)4 | No support | 49.05 | No support | (Yes)4 | (Yes)4 | ? |
Feature | Android | Chrome for Android | Edge Mobile | Firefox for Android | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic Support | 4.1 | (Yes) | (Yes) | 14.0 | 7.1 | 12.1 | (Yes) |
content-box | 4.1 | (Yes) | (Yes) | 14.0 | 7.1 | 12.1 | (Yes) |
text | ? | ? | (Yes) | 49.05 | No 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
.
© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/background-clip