Body bgColorProperty
Body Object
Definition and Usage
The bgColor property can set or return the value of the bgcolor attribute of the body element. x
The bgcolor attribute specifies the background color of the document.
Syntax
Set the bgColor property:
bodyObject.bgColor="color"
Return the bgColor property:
bodyObject.bgColor
| Value | Description |
|---|---|
| color | Specifies the background color. See the completeCSS color values |
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the bgColor property.
Examples
Examples
Return the value of the bgcolor attribute of the body element:
<html>
<body id="w3s" bgcolor="#E6E6FA">
<script>
document.write("The background color is: ")
document.write(document.getElementById("w3s").bgColor);
</script>
</body>
</html>
<body id="w3s" bgcolor="#E6E6FA">
<script>
document.write("The background color is: ")
document.write(document.getElementById("w3s").bgColor);
</script>
</body>
</html>
Try it yourself »
Body Object Other Extensions