English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
CSS background-The color attribute sets the background color of the element. You can set the background color by color values or the keyword 'transparent'.
The background of an element is the total size of the element, including padding and border (but not including margin). SeeBox model.
The following table summarizes the usage context and version history of this attribute.
Default value: | transparent |
---|---|
Applicable to: | All elements |
Inheritance: | No |
Animatable: | Yes.Please refer to Animation properties. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object object.style.backgroundColor="#00FF00" |
The syntax of this attribute is as follows:
background-color: color | transparent | initial | inherit
The following examples demonstrate how to use background-color attribute.
body { background-color: yellow;} h1 {background-color: rgb(255,0,0);} p {background-color: #00ff00;}Test to see‹/›
The following table describes the values of this attribute.
Value | Description |
---|---|
color | Specify the background color. SeeCSS color valuesto get the list of possible color values. |
transparent | Set background-Color is transparent, meaning the content and background of the element under a transparent background will be visible. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts its parent element's background-Calculated value of the color attribute. |
background-Browser compatibility of the color attribute, all mainstream browsers support this attribute.
|
Please refer to the following tutorials:CSS background,CSS3Background.
Related attributes:background,background-attachment,background-clip,background-image,background-origin,background-position,background-repeat,background-size.