CSS background-color
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The background-color
CSS property sets the background color of an element. You can set color of the background either through a color value or the keyword transparent.
The background of an element is the total size of the element, including padding and border (but not the margin). See the box model.
The following table summarizes the usages context and the version history of this property.
Default value: | transparent |
---|---|
Applies to: | All elements |
Inherited: | No |
Animatable: | Yes. See animatable properties. |
Version: | CSS 1, 2, 3 |
Syntax
The syntax of the property is given with:
The example below shows the background-color
property in action.
Example
Try this code »body {
background-color: yellow;
}
h1 {
background-color: rgb(255,0,0);
}
p {
background-color: #00ff00;
}
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
color | Specifies the background color. Look at CSS Color Values for the list of possible color values. |
transparent |
Sets the background-color to transparent i.e. content and background of the element behind the element with transparent background will be visible through. This is default. |
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element background-color property. |
Browser Compatibility
The background-color
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS Background, CSS3 Background.
Related properties: background
, background-attachment
, background-clip
, background-image
, background-origin
, background-position
, background-repeat
, background-size
.