background-color property
Specifies the color behind the content of the object.
![]() ![]() |
Syntax
background-color: transparent |
<color>
Property values
One of the following values:
transparent-
Initial value. Color of the next parent object through which the background is visible.
- color
-
Any valid color value, including those specified in the Color Table.
CSS information
| Applies To | All elements |
|---|---|
| Media | visual |
| Inherited | no |
| Initial Value | transparent |
Standards information
- CSS Backgrounds and Borders Module Level 3, Section 3.2
- CSS 2.1, Section 5.3.2
Remarks
This property can be set with the other background properties by using the background composite property.
Examples
The following examples use the background-color CSS property and the backgroundColor scripting property to specify the background color.
This example uses an inline style sheet to set the background color to "lime".
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/background-color.htm
<span style="font-size: 14px; background-color: lime">The background color of the text has been set inline using the <strong>background-color</strong> attribute.</span>
This example uses inline scripting to set the background color to "lime".
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/backgroundColor.htm
<span style="font-size: 14px" onmouseover="this.style.backgroundColor='lime'" onclick="this.style.backgroundColor='orange'" ondblclick="this.style.backgroundColor=''">Run your mouse over this text to change the background color to lime. Click to turn orange. Double-click to return to the default color.</span>
See also
Send comments about this topic to Microsoft
Build date: 11/29/2012


