The bgcolor attribute of the TABLE, TR, and TD (TH) elements specifies the background color of the table.
<table bgcolor="#0080ff"> : Applied to an entire table.
<tr bgcolor="#0080ff"> : Applied to all cells in a row.
<td bgcolor="#0080ff"> : Applied to one cell.
| Attribute | Value | Explanation |
|---|---|---|
| bgcolor=" " | color code or name | background color |
The use of this attribute is deprecated. (Use CSS instead)
Use CSS instead of deprecated HTML. Please see the "Related Document" for details on CSS.
Background color of the table
<table border="1" bgcolor="#80ffff">
<tr>
<td>Row1 - Col1</td>
<td>Row1 - Col2</td>
<td>Row1 - Col3</td>
</tr>
<tr>
<td>Row2 - Col1</td>
<td>Row2 - Col2</td>
<td>Row2 - Col3</td>
</tr>
<tr>
<td>Row3 - Col1</td>
<td>Row3 - Col2</td>
<td>Row3 - Col3</td>
</tr>
</table>
| Row1 - Col1 | Row1 - Col2 | Row1 - Col3 |
| Row2 - Col1 | Row2 - Col2 | Row2 - Col3 |
| Row3 - Col1 | Row3 - Col2 | Row3 - Col3 |
Background color of the row
<table border="1">
<tr>
<td>Row1 - Col1</td>
<td>Row1 - Col2</td>
<td>Row1 - Col3</td>
</tr>
<tr bgcolor="#ffff80">
<td>Row2 - Col1</td>
<td>Row2 - Col2</td>
<td>Row2 - Col3</td>
</tr>
<tr>
<td>Row3 - Col1</td>
<td>Row3 - Col2</td>
<td>Row3 - Col3</td>
</tr>
</table>
| Row1 - Col1 | Row1 - Col2 | Row1 - Col3 |
| Row2 - Col1 | Row2 - Col2 | Row2 - Col3 |
| Row3 - Col1 | Row3 - Col2 | Row3 - Col3 |
Background color of the cells
<table border="1"> <tr> <td>Row1 - Col1</td> <td bgcolor="#80ff80">Row1 - Col2</td> <td>Row1 - Col3</td> </tr> <tr> <td>Row2 - Col1</td> <td bgcolor="#80ff80">Row2 - Col2</td> <td>Row2 - Col3</td> </tr> <tr> <td>Row3 - Col1</td> <td bgcolor="#80ff80">Row3 - Col2</td> <td>Row3 - Col3</td> </tr> </table>
| Row1 - Col1 | Row1 - Col2 | Row1 - Col3 |
| Row2 - Col1 | Row2 - Col2 | Row2 - Col3 |
| Row3 - Col1 | Row3 - Col2 | Row3 - Col3 |
Combination
<table border="1" bgcolor="#80ffff"> <tr> <td>Row1 - Col1</td> <td bgcolor="#80ff80">Row1 - Col2</td> <td>Row1 - Col3</td> </tr> <tr bgcolor="#ffff80"> <td>Row2 - Col1</td> <td bgcolor="#80ff80">Row2 - Col2</td> <td>Row2 - Col3</td> </tr> <tr> <td>Row3 - Col1</td> <td bgcolor="#80ff80">Row3 - Col2</td> <td>Row3 - Col3</td> </tr> </table>
| Row1 - Col1 | Row1 - Col2 | Row1 - Col3 |
| Row2 - Col1 | Row2 - Col2 | Row2 - Col3 |
| Row3 - Col1 | Row3 - Col2 | Row3 - Col3 |