Body bgColorProperty

Body 对象参考手册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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>

Try it yourself »


Body 对象参考手册Body Object Other Extensions