Open In App

HTML <tr> bgcolor Attribute

Last Updated : 13 Jun, 2025
Summarize
Comments
Improve
Suggest changes
Share
Like Article
Like
Report

The HTML <tr> bgcolor Attribute is used to specify the background color of a table row. This attribute accepts color values such as color names, hex codes, or RGB values, allowing for easy customization of the background color for individual rows in an HTML table.

Note: It is not supported by HTML 5.

Syntax:

<tr bgcolor= "color_name | hex_number | rgb_number">

Attribute Values

Attribute Values

Description

color_name

It sets the background color by using the color name. For example “red”.

hex_number

It sets the background color by using the color hex code. For example “#0000ff”.

rgb_number

It sets the background color by using the RGB code. For example: “RGB(0, 153, 0)” .

Example: the implementation of <tr> bgcolor

index.html
<!DOCTYPE html>
<html>
<head>
    <title>HTML tr bgcolor Attribute</title>
    <style>
        body {
            text-align: center;
        }

        table {
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>
    <h2>
        HTML tr bgcolor Attribute
    </h2>

    <table width="500" border="1">
        <tr bgcolor="green">
            <th>Name</th>
            <th>Expenses</th>
        </tr>
        <tr bgcolor="yellow">
            <td>BITTU</td>
            <td>2500.00</td>
        </tr>
        <tr bgcolor="red">
            <td>RAKESH</td>
            <td>1400.00</td>
        </tr>
    </table>
</body>
</html>

Output:

Screenshot-2023-12-20-124909

Example: the implementation of <tr> bgcolor

index.html
<!DOCTYPE html>
<html>
<head>
    <title>
      HTML tr bgcolor Attribute Example
      </title>
    <style>
        body {
            text-align: center;
        }

        table {
            margin: 0 auto;
        }
    </style>
</head>
<body>
    <h1 style="color: green;">
        GeeksforGeeks
    </h1>

    <h2>
        HTML tr bgcolor Attribute
    </h2>
    <table width="500" border="1">
        <tr bgcolor="orange">
            <th>Fruit</th>
            <th>Color</th>
        </tr>
        <tr bgcolor="yellow">
            <td>Banana</td>
            <td>Yellow</td>
        </tr>
        <tr bgcolor="pink">
            <td>Strawberry</td>
            <td>Red</td>
        </tr>
        <tr bgcolor="lightgreen">
            <td>Apple</td>
            <td>Green</td>
        </tr>
    </table>
</body>
</html>

Output:

Screenshot-2023-12-20-125103

Browser Support

AttributeChromeEdgeFirefoxSafariOpera
<tr> bgcolor
Desktopv1v12v1v1v15
Mobilev18v4v1v14

HTML <tr> bgcolor Attribute

Similar Reads