CSS background-colorProperty
Example
Set background colors for different elements:
Try it Yourself »
Tag definition and usage instructions
The background-color property sets the background color of an element.
The background of an element is the total size of the element, including padding and border (but not margin).
| Default Value: | transparent |
|---|---|
| Inherited: | no |
| version: | CSS1 |
| JavaScript Syntax: | object object.style.backgroundColor="#0080FF" |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers immediately followed by -webkit-, -ms-, or -moz- specify the first browser version that supported the prefixed property.
| Property | |||||
|---|---|---|---|---|---|
| background-color | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
All major browsers support the background-color property.
NoteIE7 and earlier versions do not support the "inherit" value. IE8 requires a !DOCTYPE. IE9 supports "inherit".
Tips and notes
Tip:Use background colors and text colors to make text easy to read.
Property value
| Value | Description |
|---|---|
| color | Specifies the background color. InCSS Color ValuesFind a complete list of color values where possible. |
| transparent | Specifies that the background color should be transparent. This is default. |
| inherit | Specifies that the background color should be inherited from the parent element. |
Online Examples
Set the background color of some text
This example demonstrates how to set the background color of part of the text.
Related Articles
CSS Tutorial:CSS Backgrounds
other extensions