background

  • Revision slug: CSS/background
  • Revision title: background
  • Revision id: 6003
  • Created:
  • Creator: Jürgen Jeka
  • Is current revision? No
  • Comment 139 words added, 60 words removed

Revision Content

{{ CSSRef() }}

Summary

The background CSS property is a shorthand property for setting the individual background property values in a single place in the style sheet. background can be used to set the values for one or more of: {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}, {{ Cssxref("background-attachment") }}.

  • {{ Xref_cssinitial() }}: see individual properties for details
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Percentages: allowed on {{ Cssxref("background-position") }}
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: see individual properties

Syntax

background:  
[ <background-color> || <background-image> || <background-repeat> || <background-attachment> || <background-position> ]
|  {{ Cssxref("inherit") }}

 Multiple backgrounds work in Gecko 1.9.2 (Firefox 3.6)  [Update coming soon].

Values

<background-color>
See {{ cssxref("background-color") }}
<background-image>
See {{ Cssxref("background-image") }}
<background-repeat>
See {{ cssxref("background-repeat") }}
<background-attachment>
See {{ cssxref("background-attachment") }}
<background-position>
See {{ cssxref("background-position") }}

Examples

{{ CSSRefExampleLink("background") }}

body { background: red; }

.topbanner { background: url("topbanner.png") #00D repeat-y fixed; }

Notes

The background property first sets the individual background properties to their initial values, then assigns the explicit values specified in the declaration. You do not have to define a value for each of the individual properties, only those you want to change from their initial defaults.

Browser compatibility

Browser Lowest version Multiple backgrounds
Internet Explorer 4.0 ---
Firefox (Gecko) 1.0 (1.0) 3.6 (1.9.2)
Opera 3.5 ---
Safari (WebKit) 1.0 (85) 1.3 (312)

Specifications

See also

  • {{ CSS_Reference:Background() }}
  • {{ cssxref("-moz-background-size") }}, {{ cssxref("-moz-background-origin") }}, {{ cssxref("-moz-background-clip") }}, {{ cssxref("-moz-background-inline-policy") }}
  • {{ cssxref("Gradients") }}

{{ languages( { "fr": "fr/CSS/background", "it": "it/CSS/background", "pl": "pl/CSS/background", "zh-cn": "cn/CSS/background", "ko": "ko/CSS/background", "es": "es/CSS/background" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h3>Summary</h3>
<p>The<code> background </code>CSS property is a shorthand property for setting the individual background property values in a single place in the style sheet.<code> background </code>can be used to set the values for one or more of: {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}, {{ Cssxref("background-attachment") }}.</p>
<ul> <li>{{ Xref_cssinitial() }}: see individual properties for details</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Percentages: allowed on {{ Cssxref("background-position") }}</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: see individual properties</li>
</ul>
<h3>Syntax</h3>
<pre class="eval">background:  
[ &lt;background-color&gt; || &lt;background-image&gt; || &lt;background-repeat&gt; || &lt;background-attachment&gt; || &lt;background-position&gt; ]
|  {{ Cssxref("inherit") }}
</pre>
<p> Multiple backgrounds work in Gecko 1.9.2 (Firefox 3.6)  [Update coming soon].</p>
<h3>Values</h3>
<dl> <dt>&lt;background-color&gt;</dt> <dd>See {{ cssxref("background-color") }}</dd> <dt>&lt;background-image&gt;</dt> <dd>See {{ Cssxref("background-image") }}</dd> <dt>&lt;background-repeat&gt;</dt> <dd>See {{ cssxref("background-repeat") }}</dd> <dt>&lt;background-attachment&gt;</dt> <dd>See {{ cssxref("background-attachment") }}</dd> <dt>&lt;background-position&gt;</dt> <dd>See {{ cssxref("background-position") }}</dd>
</dl>
<h3>Examples</h3>
<p>{{ CSSRefExampleLink("background") }}</p>
<pre>body { background: red; }

.topbanner { background: url("topbanner.png") #00D repeat-y fixed; }
</pre>
<h3>Notes</h3>
<p>The<code> background </code>property first sets the individual background properties to their initial values, then assigns the explicit values specified in the declaration. You do not have to define a value for each of the individual properties, only those you want to change from their initial defaults.</p>
<h3>Browser compatibility</h3>
<table class="standard-table"> <tbody> <tr> <th>Browser</th> <th>Lowest version</th> <th>Multiple backgrounds</th> </tr> <tr> <td>Internet Explorer</td> <td>4.0</td> <td>---</td> </tr> <tr> <td>Firefox (Gecko)</td> <td>1.0 (1.0)</td> <td>3.6 (1.9.2)</td> </tr> <tr> <td>Opera</td> <td>3.5</td> <td>---</td> </tr> <tr> <td>Safari (WebKit)</td> <td>1.0 (85)</td> <td>1.3 (312)</td> </tr> </tbody>
</table>
<h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/CSS21/colors.html#propdef-background">CSS 2.1 Colors and backgrounds #background</a></li>
</ul>
<h3>See also</h3>
<ul> <li>{{ CSS_Reference:Background() }}</li> <li>{{ cssxref("-moz-background-size") }}, {{ cssxref("-moz-background-origin") }}, {{ cssxref("-moz-background-clip") }}, {{ cssxref("-moz-background-inline-policy") }}</li> <li>{{ cssxref("Gradients") }}</li>
</ul>
<p>{{ languages( { "fr": "fr/CSS/background", "it": "it/CSS/background", "pl": "pl/CSS/background", "zh-cn": "cn/CSS/background", "ko": "ko/CSS/background", "es": "es/CSS/background" } ) }}</p>
Revert to this revision