Changing the Background
Changing the background color of one or more cells is a great way to add visual clarity and structure to your table.
To change a cell's background color with (X)HTML:
Within the desired tag, type bgcolor= "color", where color is either a name or a hex color (see page 126 and inside back cover).
To change a cell's background image or color with CSS:
In the desired rule, type background: value, where value is described in detail on pages pages 172173.
Tips
The CSS background property is described in detail on pages 172173. This section is devoted to explaining its peculiarities with respect to tables. The CSS background property with a color value is well supported, all the way back to IE and Netscape 3. Background images are supported back to version 4 of both browsers. The (X)HTML bgcolor attribute has been deprecated. The W3C would prefer you use the CSS background property. Nevertheless, bgcolor continues to be well supported. You can add the bgcolor attribute to any table tag (table, tr, thead, etc.) to change the color of the cells in one or more rows or columns at once. The bgcolor attribute 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 CSS Colors on page 126 and the inside back cover for help choosing colors.
You can add both a background image and a background color to a cell. The background color will display before the image and then continue to shine through the transparent parts of the image, if there are any. You can also set the color of the contents of a cell. For details, see Setting the Color on page 160. For information about changing the color of the borders, consult Adding a Border on page 230. Make sure that your background images do not distract from the content that is placed on top of them. I am continually amazed at how many sites use bizarrely busy backgrounds with text that is for all intents and purposes illegible.
|