The best CSS background-color attribute Tutorial In 2024, In this tutorial you can learn Examples,Tag definitions and instructions,Browser Support,Tips and Notes,Property Value,Online examples,related articles,
Set the background color of different elements:
background-color property sets the background color of an element.
The total size of the background elements of the element, including padding and border (but not including margins).
Defaults: | transparent |
---|---|
inherit: | no |
version: | CSS1 |
JavaScript syntax: | object object.style.backgroundColor = "# 00FF00" |
Figures in the table represent the first browser to support the version number of the property.
Immediately following the digital -webkit-, -ms- or -moz- ago in support of the prefix attribute first browser version number.
属性 | |||||
---|---|---|---|---|---|
background-color | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
All major browsers support background-color property.
Note that IE7 and earlier versions do not support "inherit" value.IE8 need to define! DOCTYPE. IE9 support the "inheritance."
Tip: Use thebackground and text colors to make the text easier to read.
value | description |
---|---|
color | Specifies the background color. In value CSS color as possible to find a complete list of color values. |
transparent | Specifies the background color should be transparent. This is the default |
inherit | Specifies the background color should be inherited from the parent element |
Setting part of the text background color
This example demonstrates how to set part of the text background color.
CSS tutorial: CSS background