mozilla

Revision 21247 of background-color

  • Revision slug: CSS/background-color
  • Revision title: background-color
  • Revision id: 21247
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment 43 words added, 72 words removed

Revision Content

{{ CSSRef() }}

Summary

The background-color CSS property sets the background color of an element, either through a color value or the keyword transparent.

  • {{ Xref_cssinitial() }}: transparent
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Percentages: N/A
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

background-color: color | inherit

Values

color 
Is a CSS {{ xref_csscolor() }} that describes the uniform color of the background. Even if one or several {{ cssxref("background-image") }} are defined, this color can be affect the rendering, by transparency if the images aren't opaque.

Examples

{{ CSSRefExampleLink("background-color") }}

.exampleOne {
	background-color: teal;
	color: white;
}

.exampleTwo {
	background-color: rgb(153,102,153);
	color: rgb(255,255,204);
}

.exampleThree {
	background-color: #666699;
	color: #FFFFFF;
}

Specifications

Specification Status Comment
CSS Backgrounds and Borders Module Level 3 {{ Spec2('CSS3 Backgrounds') }} Though technically removing the transparent keyword, this doesn't change anything as it has been incorporated as a true {{ xref_csscolor() }}
CSS 2.1 {{ Spec2('CSS2.1') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari (WebKit)
Basic support {{ CompatGeckoDesktop("1.0") }} 1.0 4.0 3.5 1.0 (85)
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatGeckoMobile("1.9.2") }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }} {{ CompatVersionUnknown() }}

See also

{{ languages( { "de": "de/CSS/background-color", "es": "es/CSS/background-color", "fr": "fr/CSS/background-color", "it": "it/CSS/background-color", "ja": "ja/CSS/background-color", "pl": "pl/CSS/background-color" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2>Summary</h2>
<p>The <code>background-color</code> <a href="/en/CSS" title="CSS">CSS</a> property sets the background color of an element, either through a color value or the keyword <code>transparent</code>.</p>
<ul class="cssprop"> <li>{{ Xref_cssinitial() }}: <code>transparent</code></li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Percentages: N/A</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as specified</li>
</ul>
<h2 name="Syntax">Syntax</h2>
<pre class="eval syntaxbox">background-color: <em>color</em> | <a href="/en/CSS/inherit" title="inherit">inherit</a>
</pre>
<h3 name="Values">Values</h3>
<dl> <dt><em>color</em> </dt> <dd>Is a CSS {{ xref_csscolor() }} that describes the uniform color of the background. Even if one or several {{ cssxref("background-image") }} are defined, this color can be affect the rendering, by transparency if the images aren't opaque.</dd>
</dl>
<h3 name="Examples">Examples</h3>
<p>{{ CSSRefExampleLink("background-color") }}</p>
<pre>.exampleOne {
	background-color: teal;
	color: white;
}

.exampleTwo {
	background-color: rgb(153,102,153);
	color: rgb(255,255,204);
}

.exampleThree {
	background-color: #666699;
	color: #FFFFFF;
}

</pre>
<h2 name="Browser_Compatibility">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/css3-background/#background-color" title="http://www.w3.org/TR/css3-background/#background-color">CSS Backgrounds and Borders Module Level 3</a></td> <td>{{ Spec2('CSS3 Backgrounds') }}</td> <td>Though technically removing the <code>transparent</code> keyword, this doesn't change anything as it has been incorporated as a true {{ xref_csscolor() }}</td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS21/colors.html#propdef-background-color" title="http://www.w3.org/TR/CSS21/colors.html#propdef-background-color">CSS 2.1</a></td> <td>{{ Spec2('CSS2.1') }}</td> <td> </td> </tr> </tbody>
</table>
<h2 name="Browser_Compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Firefox (Gecko)</th> <th>Chrome</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari (WebKit)</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatGeckoDesktop("1.0") }}</td> <td>1.0</td> <td>4.0</td> <td>3.5</td> <td>1.0 (85)</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Firefox Mobile (Gecko)</th> <th>Android</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatGeckoMobile("1.9.2") }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> <td>{{ CompatVersionUnknown() }}</td> </tr> </tbody> </table>
</div>
<h2>See also</h2>
<ul> <li>{{ CSS_Reference:Background() }}</li> <li><a href="/en/CSS/Multiple_backgrounds" title="en/CSS/Multiple backgrounds">Multiple backgrounds</a></li>
</ul>
<p>{{ languages( { "de": "de/CSS/background-color", "es": "es/CSS/background-color", "fr": "fr/CSS/background-color", "it": "it/CSS/background-color", "ja": "ja/CSS/background-color", "pl": "pl/CSS/background-color" } ) }}</p>
Revert to this revision