X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Body bgColor Property

Body Object Reference Body Object

Definition and Usage

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

The bgcolor attribute specifies the background color of a document.

Syntax

Set the bgColor property:

bodyObject.bgColor="color"

Return the bgColor property:

bodyObject.bgColor

Value Description
color Specifies the background color. Look at CSS Color Values for a complete list of possible color values


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The bgColor property is supported in all major browsers.


Example

Example

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 Object Reference Body Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook