background-origin

  • Revision slug: CSS/background-origin
  • Revision title: background-origin
  • Revision id: 28805
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 34 words added, 18 words removed

Revision Content

{{ CSSRef() }}

Summary

The background-origin CSS property determines the background positioning area, that is the position of the origin of an image specified using the {{ cssxref("background-image") }} CSS property.

Note that background-origin is ignored when {{ Cssxref("background-attachment") }} is fixed.

If the value of this property is not set in a {{ cssxref("background") }} shorthand property that is applied to the element after the background-origin CSS property, the value of this property is then reset to its initial value by the shorthand property.
  • {{ Xref_cssinitial() }}: padding-box
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

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

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.

Examples

 .example {
   border: 10px double;
   padding: 10px;
   background: url('image.jpg');
   background-position: center left;
   /* The background will be inside the padding */       
   background-origin: content-box;
}
div {
  background-image: url('mainback.png'), url('logo.jpg');
  background-position: 0px 0px, top right;
  background-origin: padding-box, content-box;
}

Specifications

Specification Status Comment
CSS Backgrounds and Borders Module Level 3 {{ Spec2('CSS3 Backgrounds') }}  

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-origin: padding | border.

[2] Internet Explorer up to version 7 behaves as if there was a background-origin: border-box; Internet Explorer 8 behaves as if it were background-origin: padding-box; which is the regular default value.

[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-origin.

See also

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

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

Revision Source

<p>{{ CSSRef() }}</p>
<h2>Summary</h2>
<p>The<code> background-origin </code>CSS property determines the background positioning area, that is the position of the origin of an image specified using the {{ cssxref("background-image") }} CSS property.</p>
<p>Note that <code>background-origin</code> is ignored when {{ Cssxref("background-attachment") }} is <code><code>fixed</code></code>.</p>
<div class="note">If the value of this property is not set in a {{ cssxref("background") }} shorthand property that is applied to the element after the <code>background-origin</code> CSS property, the value of this property is then reset to its initial value by the shorthand property.</div>
<ul class="cssprop"> <li>{{ Xref_cssinitial() }}: <code>padding-box</code></li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as specified<br> <code> </code></li>
</ul>
<h2>Syntax</h2>
<pre class="syntaxbox">background-origin: [<code>padding-box | border-box | conten</code><code>t-box</code>][, [<code>border-box | padding-box | conten</code><code>t-box</code>]]*
</pre>
<h2>Values</h2>
<dl> <dt>border-box</dt> <dd>The background extends to the outside edge of the border (but underneath the border in z-ordering).</dd> <dt>padding-box</dt> <dd>No background is drawn below the border (background extends to the outside edge of the padding).</dd> <dt>content-box</dt> <dd>The background is painted within (clipped to) the content box.</dd>
</dl>
<h2>Examples</h2>
<pre> .example {
   border: 10px double;
   padding: 10px;
   background: url('image.jpg');
   background-position: center left;
   /* The background will be inside the padding */       
   background-origin: content-box;
}
</pre>
<pre>div {
  background-image: url('mainback.png'), url('logo.jpg');
  background-position: 0px 0px, top right;
  background-origin: padding-box, content-box;
}
</pre>
<h2>Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS21/colors.html#propdef-background-origin" title="http://www.w3.org/TR/CSS21/colors.html#propdef-background-origin">CSS Backgrounds and Borders Module Level 3</a></td> <td>{{ Spec2('CSS3 Backgrounds') }}</td> <td> </td> </tr> </tbody>
</table>
<h2>Browser compatibility</h2>
<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-origin: padding | border</code>.</p>
<p>[2] Internet Explorer up to version 7 behaves as if there was a <code>background-origin: border-box;</code> Internet Explorer 8 behaves as if it were <code>background-origin: padding-box;</code> which is the regular default value.</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-origin</code>.</p><h2>See also</h2>
<ul> <li>{{ cssxref("-moz-background-size") }}</li> <li>{{ CSS_Reference:Background() }}</li>
</ul>
<p>{{ languages( { "de":"de/CSS/background-origin", "fr": "fr/CSS/-moz-background-origin", "ja": "ja/CSS/-moz-background-origin", "pl": "pl/CSS/-moz-background-origin" } ) }}</p>
Revert to this revision