HTML <th> bgcolor Attribute (original) (raw)

Last Updated : 22 May, 2026

The bgcolor attribute in the tag is used to set the background color of a header cell. It was commonly used in older HTML but is now deprecated in HTML5.

**Note: It is not supported by HTML5.

Syntax

Attribute Values

**Example 1: Using Color name

html `

HTML th bgcolor Attribute

GeeksforGeeks

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

GeeksforGeeks

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>

`