HTML <th> bgcolor Attribute (original) (raw)
Last Updated : 22 May, 2026
The bgcolor attribute in the
- Sets the background color of a header cell.
- Accepts color names, hex codes, or RGB values.
- Used only with the
element.
**Note: It is not supported by HTML5.
Syntax
Attribute Values
- **color_name: Sets background color using a color name (e.g., "red")
- **hex_number: Sets background color using a hex code (e.g., "#0000ff")
- **rgb_number: Sets background color using RGB values (e.g., "rgb(0, 153, 0)")
**Example 1: Using Color name
html `
HTML th bgcolor AttributeGeeksforGeeks
<h2>HTML th bgcolor Attribute</h2>
<table width="500" border="1">
<tr>
<th bgcolor="green">Name</th>
<th bgcolor="yellow">Expenses</th>
</tr>
<tr>
<td>Ben</td>
<td>2500.00</td>
</tr>
<tr>
<td>Ron</td>
<td>1400.00</td>
</tr>
</table>
`
**Example 2: Using rgb number
HTML `
HTML th bgcolor AttributeGeeksforGeeks
HTML th bgcolor Attribute
<table width="500" border="1">
<tr>
<!-- Using Hex Number -->
<th bgcolor="#00FF00">Name</th>
<!-- Using RGB Number -->
<th bgcolor="rgba(255, 255, 0)">Expenses</th>
</tr>
<tr>
<td>Ben</td>
<td>2500.00</td>
</tr>
<tr>
<td>Ron</td>
<td>1400.00</td>
</tr>
</table>
`