CSS GUIDE BACKGROUND COLOR
Contents
Summary
background-color sets the background color of an element, either through a color value or the keyword transparent.
- Initial value: transparent
- Applies to: all elements
- Inherited: no
- Percentages: N/A
- Media: visual
- Computed value: as specified
Syntax
background-color: color | transparent | inherit
Legal Values
color
- The color can be specified as a hexidecimal RGB value, a regular RGB value, or by using one of the pre-defined color keywords.
transparent
- The default value for background-color is transparent meaning the element has no color of its own, instead showing the color of the element behind it.
Mozilla Recommended Values
Usage Examples
.exampleone { background-color: teal; color: white; } .exampletwo { background-color: rgb(153,102,153); color: rgb(255,255,204); } .examplethree { background-color: #666699; color: #FFFFFF; }
Notes
- Valid color names you can use in HTML and CSS instead of numerical color values
- Proprietary color names used by Internet Explorer and their numerical equivalents
- 216-color Websafe palette and the 22-color Reallysafe palette
- Several Colour Charts
- 147 color names supported by popular browsers