Style backgroundColorProperty
Example
Set the background color of the document:
document.body.style.backgroundColor="#f3f3f3";
Try it Yourself »
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 only supports "inherit" 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
Property Values
| Value | Description |
|---|---|
| color | Specifies the background color. InCSS color valuesfind a complete list of possible color values. |
| inherit | The background color is inherited from the parent element. |
| transparent | Default. The background color is transparent (the underlying content will show through). |
Technical Details
| Default value: | transparent |
|---|---|
| Return value: | A string representing the background color |
| DOM Version | Core Level 1 |
Style Object Other Extensions