bgcolor (HTML attribute)
Example
This markup sets the
bgcolor for this document to
"yellow":
<body bgcolor="yellow"> … </body>
Description
By default, in the current set
of web browsers, a page will have a white background and black text. The
bgcolor attribute of the body
element provides a mechanism for changing the default background color,
although it should be noted that this attribute is now deprecated and the
best method would be to set the background color using Cascading Style
Sheets (CSS).
Value
This attribute
takes a recognized color name (for
example, "blue" or "red") or
a value specified in hexadecimal notation (such as
"#003366"). Note that it’s not possible to use
shorthand hex values for the bgcolor in HTML as you
can in CSS (for example, you can’t express "#cceeff" as
"#cef").
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Every browser listed supports this attribute.
User-contributed notes
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

