HTML DOM Body bgColor property
Definition and Usage
bgColor property sets or returns the value of the bgcolor attribute of the body element. x
bgcolor attribute specifies the background color of the document.
grammar
Setting bgColor properties:
bodyObject.bgColor="color"
Back bgColor properties:
bodyObject.bgColor
值 | 描述 |
---|---|
color | 指定了背景颜色。查看完整的 CSS 颜色值 |
Browser Support
All major browsers support bgColor property
Examples
Examples
Back 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"
Body Object