Skip to: content, navigation

by Ian Lloyd

bgcolor (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
Yes HTML 2
bgcolor="colorname/#hexvalue"

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

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters