bgColor property (document)
Sets or retrieves the background color of the document.
Deprecated, it is no longer recommended to use.
You can set the background color for the document with the backgroundColor style property of the body element.
See Example 2 for details.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
Possible values:
A legal color value. It can be a hexadecimal, RGB or predefined color value. For more information, see the page for colors.
Default: this property has no default value.
Example HTML code 1:
This example illustrates the use of the bgColor property:
|
||||
<head> <script type="text/javascript"> function ChangeBg () { document.bgColor = "cyan"; } </script> </head> <body> <button onclick="ChangeBg();">Change bgColor</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
Recommendation (backgroundColor):
|
||||
<head> <style> body { background-color:#FF0000; } </style> <script type="text/javascript"> function ChangeBg () { document.body.style.backgroundColor = "#00FF00"; } </script> </head> <body> <button onclick="ChangeBg();">Change backgroundColor</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments