background-clip
Specifies the area within which the background is painted.
Sample Code
div.test { background-clip: border-box;}
div.test1 { background-clip: content-box;}
div.test2 { background-clip: padding-box;}
Available Values
| Value | Description |
|---|---|
| border-box | Paints the background up to the outer edge of the border. This is the default value. |
| content-box | Paints the background only within the content area (excluding padding and border). |
| padding-box | Paints the background up to the outer edge of the padding. |
Browser Preview
<div style="border: dashed 10px #00f; height: 100px; padding: 10px; background-color: #ff0; background-clip: border-box;">A 100px tall div with 10px padding. 'background-clip: border-box' paints the background up to the outer border edge. Background color is '#ff0', border is 'dashed 10px #00f'.</div>
<div style="border: dashed 10px #00f; height: 100px; padding: 10px; background-color: #ff0; background-clip: content-box;">A 100px tall div with 10px padding. 'background-clip: content-box' paints the background only within the content area (inside padding). Background color is '#ff0', border is 'dashed 10px #00f'.</div>
<div style="border: dashed 10px #00f; height: 100px; padding: 10px; background-color: #ff0; background-clip: padding-box;">A 100px tall div with 10px padding. 'background-clip: padding-box' paints the background up to the outer edge of the padding. Background color is '#ff0', border is 'dashed 10px #00f'.</div>
Browser Compatibility
Desktop
3 △
2 △
1 △↑ Requires prefix
-moz-
4 △
3 △↑ Requires prefix
-webkit-
2 and below ×Supported in all versions.
8 ×
7 ×
6 ×
9 and below ×Mobile
4 △
3 △
2 △
1 △↑ Requires prefix
-webkit-
Android Browser
4.4+ ○
3 and below ×Same support as desktop.
Same support as desktop.
Notes
Specifies the area within which the background is painted.
By default, the background extends to the outer edge of the border. With the background-clip property, you can restrict the background to the content area (excluding padding) or just the padding area. Compare the yellow background extents in the samples above.
If you find any errors or copyright issues, please contact us.