Using Color in HTML Tables

Deprecated

The bgcolor attribute is deprecated.

This code should not be used:
bgcolor="red"
bgcolor="#ff0000"

If you are using a WYSIWYG editor that uses the bgcolor attribute, get rid of it.

Use CSS

It is replaced with CSS:
td {
background: #ff0000
}

or
td {
background-color: #ff0
}

 

Example Table

Heading
Column 1 Column 2

The Code

The code shows the different methods of setting background colors.

<table STYLE="width: 400px; background :#7F7F7F;padding: 10px; border: none; border-radius: 10px; box-shadow: 5px 5px 10px #0e0e0e">
<tr><th STYLE="background-color :#E4B552;padding: 5px" colspan="2">Heading</th></tr>
<tr>
<td class="yellow-column">Column 1</td>
<td id="red-column">Column 2</td>
</tr></table>

The class and id identifiers are shown below:

td.yellow-column {
background-color: #ffff00
}
#red-column {
background: #ff8080
}