background-clip

  • Revision slug: CSS/background-clip
  • Revision title: background-clip
  • Revision id: 6342
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment one or more formatting changes

Revision Content

{{ CSSRef() }}

Summary

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

-moz-background-clip is supported up to Gecko version 1.9.2 (Firefox 3.6). To support both, older and newer versions of Gecko (Firefox), you have to add both properties in the stylesheet (see examples).

If there is no background-image, this property has only visual effect when the border has transparent regions (because of {{ Cssxref("border-style") }}) or partially opaque regions; otherwise the border covers up the difference.

  • {{ Xref_cssinitial() }}: border-box
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

background-clip:  [ border-box | padding-box | content-box][, [ border-box | padding-box | content-box]]*

-moz-background-clip:  [border | padding][, [border | padding]]*   /* Gecko 1.2-1.9.2 (Firefox 1.0-3.6) */

Values

border-box {{ gecko_minversion_inline("2.0") }}
border (Firefox 1.0-3.6)
The background extends to the outside edge of the border (but underneath the border in z-ordering).
Default value, but see {{ anch("Browser compatibility") }} section below for special case Internet Explorer 7.
padding-box {{ gecko_minversion_inline("2.0") }}
padding (Firefox 1.0-3.6)
No background is drawn below the border (background extends to the outside edge of the padding).
content-box {{ gecko_minversion_inline("2.0") }}
The background is painted within (clipped to) the content box.

Examples

 pre {
   border: 5px navy;
   border-style: dotted double;
   background: #F8D575;
   /* The yellow background will not go behind the border */
      -moz-background-clip: padding;      /* Firefox 1.0-3.6 */
   -webkit-background-clip: padding-box;  /* Safari, Chrome */
           background-clip: padding-box;  /* Firefox 4.0+, Opera 10.5, Chrome */
 }

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 [3] {{ CompatGeckoDesktop("2.0") }} [1] 9.0 [2] 10.5 3.0 (522) [3]
content-box 1.0 [3] {{ CompatGeckoDesktop("2.0") }} [1] 9.0 [2] {{ CompatNo() }} 3.0 (522) [3]
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
content-box {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

[1] 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.

[2] Internet Explorer 7, but not other versions of Internet Explorer,behaves like background-clip:padding if overflow: hidden | auto | scroll.

[3] Webkit also supports the prefixed version of this proprietary, and in that case, in addition to the current keywords, the alternative synonyms: padding, border, and content.

[4] Konqueror 3.5.4 supports -khtml-background-clip.

Specifications

See also

  • {{ cssxref("-moz-background-size") }}
  • {{ CSS_Reference:Background() }}
  • {{ cssxref("clip") }}

{{ languages( { "de": "de/CSS/background-clip", "fr": "fr/CSS/-moz-background-clip", "ja": "ja/CSS/-moz-background-clip", "pl": "pl/CSS/-moz-background-clip" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The<code> background-clip </code>CSS property specifies whether an element's background, either the color or image, extends underneath its border.</p>
<p><code>-moz-background-clip </code>is supported up to Gecko version 1.9.2 (Firefox 3.6). To support both, older and newer versions of Gecko (Firefox), you have to add both properties in the stylesheet (see examples).</p>
<p>If there is no background-image, this property has only visual effect when the border has transparent regions (because of {{ Cssxref("border-style") }}) or partially opaque regions; otherwise the border covers up the difference.</p>
<ul> <li>{{ Xref_cssinitial() }}:<code> border-box</code></li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as specified</li>
</ul>
<h3>Syntax</h3>
<pre>background-clip:  [ border-box | padding-box | content-box][, [ border-box | padding-box | content-box]]*

-moz-background-clip:  [border | padding][, [border | padding]]*   /* Gecko 1.2-1.9.2 (Firefox 1.0-3.6) */
</pre>
<h3>Values</h3>
<dl> <dt>border-box {{ gecko_minversion_inline("2.0") }}<br> border <small>(Firefox 1.0-3.6)</small></dt> <dd>The background extends to the outside edge of the border (but underneath the border in z-ordering).<br> Default value, but see {{ anch("Browser compatibility") }} section below for special case Internet Explorer 7.</dd> <dt>padding-box {{ gecko_minversion_inline("2.0") }}<br> padding <small>(Firefox 1.0-3.6)</small></dt> <dd>No background is drawn below the border (background extends to the outside edge of the padding).</dd> <dt>content-box {{ gecko_minversion_inline("2.0") }}</dt> <dd>The background is painted within (clipped to) the content box.</dd>
</dl>
<h3>Examples</h3>
<pre style="overflow:visible; border:5px navy; border-style:dotted double; background: #F8D575; -moz-background-clip:padding; -webkit-background-clip:padding; background-clip:padding-box;"> pre {
   border: 5px navy;
   border-style: dotted double;
   background: #F8D575;
   /* The yellow background will not go behind the border */
      -moz-background-clip: padding;      /* Firefox 1.0-3.6 */
   -webkit-background-clip: padding-box;  /* Safari, Chrome */
           background-clip: padding-box;  /* Firefox 4.0+, Opera 10.5, Chrome */
 }
</pre>
<h3>Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>1.0 [3]</td> <td>{{ CompatGeckoDesktop("2.0") }} [1]</td> <td>9.0 [2]</td> <td>10.5</td> <td>3.0 (522) [3]</td> </tr> <tr> <td><code>content-box</code></td> <td>1.0 [3]</td> <td>{{ CompatGeckoDesktop("2.0") }} [1]</td> <td>9.0 [2]</td> <td>{{ CompatNo() }}</td> <td>3.0 (522) [3]</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> <tr> <td><code>content-box</code></td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<p>[1] 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: <code>-moz-background-clip: padding | border</code>.</p>
<p>[2] Internet Explorer 7, but not other versions of Internet Explorer,behaves like<code> background-clip:padding </code>if<code> overflow: hidden | auto | scroll</code>.</p>
<p>[3] Webkit also supports the prefixed version of this proprietary, and in that case, in addition to the current keywords, the alternative synonyms: <code>padding</code>, <code>border</code>, and <code>content</code>.</p>
<p>[4] Konqueror 3.5.4 supports<code> -khtml-background-clip</code>.</p><h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/css3-background/#the-background-clip" title="http://www.w3.org/TR/css3-background/#the-background-clip">CSS 3 Backgrounds and Borders #background-clip</a></li> <li><a class=" external" href="http://dev.w3.org/csswg/css3-background/#the-background-clip" title="http://dev.w3.org/csswg/css3-background/#the-background-clip">Latest Editor's Draft</a> (includes <code>content-box</code>)</li>
</ul>
<h3>See also</h3>
<ul> <li>{{ cssxref("-moz-background-size") }}</li> <li>{{ CSS_Reference:Background() }}</li> <li>{{ cssxref("clip") }}</li>
</ul>
<p>{{ languages( { "de": "de/CSS/background-clip", "fr": "fr/CSS/-moz-background-clip", "ja": "ja/CSS/-moz-background-clip", "pl": "pl/CSS/-moz-background-clip" } ) }}</p>
Revert to this revision