You are here: Reference > JavaScript > client-side > HTML DOM > properties > bgColor (body, table, td, ...)
bgColor property (body, table, td, ...)
Sets or retrieves the background color.
This property is deprecated. Use the backgroundColor style property instead.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
HTML page for this property: bgColor |
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 attribute:
|
||||
<body bgcolor="red"> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
Recommendation:
|
||||
<body style="background-color:red;"> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 3:
This example illustrates the use of the bgColor property:
|
||||
<head> <script type="text/javascript"> function ChangeToGreen () { document.body.bgColor = "green"; } </script> </head> <body bgcolor="red"> <button onclick="ChangeToGreen ();">Change the background color to green</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments