Chapter 9: Tables
index | previous | next

Changing a Cell’s Color

Changing the color of one or more cells is a great way to add visual clarity and structure to your table.

To change a cell’s color:

  1. Within the TD tag, type BGCOLOR=.
  2. Type "#rrggbb", where rrggbb is the hexadecimal representation of the desired color.
  3. Or type color, where color is one of the sixteen predefined color names (see inside back cover).

Tips

  • You can change the color of the cells in one or more rows or columns by adding the BGCOLOR attribute to the appropriate tag (TR, THEAD, TFOOT, TBODY, COLGROUP, or COL).
  • Explorer supports using BGCOLOR in the TABLE tag for changing the background of the whole table.
  • The BGCOLOR in an individual cell (TH or TD) overrides the color specified in a row (in a TR tag), which in turn overrides the color specified for a group of rows or columns (in THEAD, COLGROUP, etc.), which, as you might expect, overrides the color specified for the entire table (in the TABLE tag).
  • Consult Colors in Hex on page 357 and the inside back cover for help choosing colors.
  • BGCOLOR has been deprecated in HTML 4. The W3C recommends the use of styles to change the background color (see page 286).
Figure 9.32 I’ve changed the background color of the navigation bar to help tie it to the logo in the upper left-hand corner. I’ve also changed the link’s color on the page to make the links stand out better on the dark green background chosen.
Figure 9.33 Changing the color of a column really makes it stand out. Since it matches the color in the logo, it helps to pull the whole design together as well.
previous | next