<table bgcolor=""><tr bgcolor=""><td bgcolor="">

Browser
  • IE
  • Cr
  • Sf
  • Fx
  • O
Type

The bgcolor attribute of the TABLE, TR, and TD (TH) elements specifies the background color of the table.


<table bgcolor="#0080ff"></table> : Applied to an entire table

<tr bgcolor="#0080ff"></tr> : Applied to all cells in a row

<td bgcolor="#0080ff"></td> : Applied to one cell

Attribute Value Explanation
bgcolor=" " color code or name background color

The use of this attribute is deprecated. (Use CSS instead)

Example

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>

Output
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>

Output
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>

Output
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>

Output
Row1 - Col1 Row1 - Col2 Row1 - Col3
Row2 - Col1 Row2 - Col2 Row2 - Col3
Row3 - Col1 Row3 - Col2 Row3 - Col3