Body bgColor property

HTML DOM Body bgColor attribute Body object

Definitions and usages

The bgColor property sets or returns the bgcolor property value of the body element.

The bgcolor property specifies the background color of the document.

Grammar

Set the bgColor property:

bodyObject.bgColor=" color "

Return bgColor property:

bodyObject.bgColor

value describe
color Specifies the background color.View full CSS color value


Browser support

HTML DOM Body bgColor attribute HTML DOM Body bgColor attribute HTML DOM Body bgColor attribute HTML DOM Body bgColor attribute HTML DOM Body bgColor attribute

The bgColor property is supported by all major browsers


Returns the bgcolor property value 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 out . . .


HTML DOM Body bgColor attribute Body object