Style backgroundColor property
Example
Set the background color of the document:
document.body.style.backgroundColor="#f3f3f3";
Try it »
Definition and Usage
The backgroundColor property sets or returns the background color of an element.
Browser support





All major browsers support the backgroundColor property.
**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".
Syntax
Set the backgroundColor property:
element
.style.backgroundColor="
color
|inherit|transparent"
Return the backgroundColor property:
element
.style.backgroundColor
Attribute values
| Value | Description |
|---|---|
| color | Specifies the background color. In A CSS color valuethe CSS color reference you can find a complete list of possible color values. |
| inherit | The background color is inherited from the parent element. |
| transparent | Default. The background color is transparent (underlying content will show through). |
Technical Details
| Default value: | transparent |
|---|---|
| Return Value: | A string representing the background color |
| DOM version | Core Level 1 |
The Style object