mozilla

Revision 6002 of background

  • Revision slug: CSS/background
  • Revision title: background
  • Revision id: 6002
  • Created:
  • Creator: Ed.Kick.Tiger
  • Is current revision? No
  • Comment Reverted to earlier version; 10 words removed; page display name reset to default

Revision Content

{{ CSSRef() }}

Summary

The background 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-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}.

  • {{ 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") }} ;

Values

background-color
See background-color.
background-image 
See background-image.
background-repeat 
See background-repeat.
background-attachment 
See background-attachment.
background-position 
See background-position.

Examples

{{ CSSRefExampleLink("background") }}

body { 
    background: red;
}

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

Notes

Given a valid declaration, 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.

Specifications

Browser Compatibility

Browser Lowest Version
Internet Explorer 4
Firefox 1
Netscape 6
Opera 3.5

See Also

{{ Cssxref("background") }}, {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}


Categorias

Interwiki Language Links


{{ 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 name="Summary"> Summary </h3>
<p>The <code>background</code> 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-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}.
</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 name="Syntax"> Syntax </h3>
<pre class="eval">background: [  <em>&lt;background-color&gt;</em>    ||  <em>&lt;background-image&gt;</em>       ||
               <em>&lt;background-repeat&gt;</em>   ||  <em>&lt;background-attachment&gt;</em>  ||
               <em>&lt;background-position&gt;</em>
            ]   |   {{ Cssxref("inherit") }} ;
</pre>
<h3 name="Values"> Values </h3>
<dl><dt> background-color</dt><dd> See <code><a href="en/CSS/background-color">background-color</a></code>.
</dd><dt> background-image </dt><dd> See <code><a href="en/CSS/background-image">background-image</a></code>.
</dd><dt> background-repeat </dt><dd> See <code><a href="en/CSS/background-repeat">background-repeat</a></code>.
</dd><dt> background-attachment </dt><dd> See <code><a href="en/CSS/background-attachment">background-attachment</a></code>.
</dd><dt> background-position </dt><dd> See <code><a href="en/CSS/background-position">background-position</a></code>.
</dd></dl>
<h3 name="Examples"> Examples </h3>
<p>{{ CSSRefExampleLink("background") }}
</p>
<pre>body { 
    background: red;
}

.topbanner {
    background: url("topbanner.png") #00D repeat fixed;
}
</pre>
<h3 name="Notes"> Notes </h3>
<p>Given a valid declaration, 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 name="Specifications"> Specifications </h3>
<ul><li> <a class="external" href="http://www.w3.org/TR/CSS1#background">CSS 1</a>
</li><li> <a class="external" href="http://www.w3.org/TR/CSS21/colors.html#propdef-background">CSS 2.1</a>
</li><li> <a class="external" href="http://www.w3.org/TR/2005/WD-css3-background-20050216/#the-background">CSS 3</a>
</li></ul>
<h3 name="Browser_Compatibility"> Browser Compatibility </h3>
<table class="standard-table"> <tbody><tr> <th>Browser</th> <th>Lowest Version</th> </tr> <tr> <td>Internet Explorer</td> <td>4</td> </tr> <tr> <td>Firefox</td> <td>1</td> </tr> <tr> <td>Netscape</td> <td>6</td> </tr> <tr> <td>Opera</td> <td>3.5</td> </tr>
</tbody></table>
<h3 name="See_Also"> See Also </h3>
<p>{{ Cssxref("background") }}, {{ Cssxref("background-attachment") }}, {{ Cssxref("background-color") }}, {{ Cssxref("background-image") }}, {{ Cssxref("background-position") }}, {{ Cssxref("background-repeat") }}
</p><p><br>
<span class="comment">Categorias</span>
</p><p><span class="comment">Interwiki Language Links</span>
</p><p><br>
</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" } ) }}
Revert to this revision