HTML Code Tutorial

Color in Tables

For browser compatibility color settings in tables should use the inline bgcolor attribute:
bgcolor="red"
bgcolor="#ff0000"

Tags that accept the bgcolor attribute are:
<table>(IE, Moz)
<th>
<td>

Heading
Column 1 Column 2

The code below shows how to set the color within the tags that accept the bgcolor attribute, to produce the table exhibited above..

<table width="200" cellpadding="2" cellspacing="15" border="0" bgcolor="#7F7F7F">
<tr><th colspan="2" bgcolor="#00FF00">Heading</th></tr>
<tr>
<td bgcolor="#FF8080">Column 1</td>
<td bgcolor="#FFFF00">Column 2</td>
</tr></table>

Note: If you are viewing this page in a Mozilla browser the appearance of the table may be quite different than that of the IE display.

Using Inline Style Sheets

Similar results can be obtained using Inline Style sheets. There are still problems with browser compatibility using this method in tables. The code and resulting table, below.

<table STYLE="background-color :#7F7F7F" width="200" cellpadding="2" cellspacing="15" border="0">
<tr><th STYLE="background-color :#E4B552" colspan="2">Heading</th></tr>
<tr align="center" valign="top">
<td STYLE="background-color :#FFFF00">Column 1</td>
<td STYLE="background-color :#FF8080">Column 2</td>
</tr></table>

Heading
Column 1 Column 2