HTML DOM backgroundColor Property
Complete Style Object Reference
Definition and Usage
The backgroundColor property sets the background color of an element.
Syntax
Object.style.backgroundColor=color-name|color-rgb
|color-hex|transparent
|
Example
The following example changes the background color of the body:
<html>
<head>
<style type="text/css">
body
{
background-color:#B8BFD8;
}
</style>
<script type="text/javascript">
function changeStyle()
{
document.body.style.backgroundColor="#FFCC80";
}
</script>
</head>
<body>
<input type="button" onclick="changeStyle()"
value="Change background color" />
</body>
</html>
|
Try-It-Yourself Demos
Change the background color (hex)
Change the background color (color name)
Complete Style Object Reference
Learn XML with <oXygen/> XML Editor - Free Trial!
|
|
oXygen helps you learn to define,
edit, validate and transform XML documents. Supported technologies include XML Schema,
DTD, Relax NG, XSLT, XPath, XQuery, CSS.
Understand in no time how XSLT and XQuery work by using the intuitive oXygen debugger!
Do you have any XML related questions? Get free answers from the oXygen
XML forum
and from the video
demonstrations.
Download a FREE 30-day trial today!
|
|