HTML slt;tr> bgcolor properties

HTML tr bgcolor attribute HTML and tr;tags

When you build a table, if you need to add a background color to a row in a table, you can use the bgcolor property, as in the following example, to add a background color to the first row of the table, and you can try adding a background color to the second row of the table (refer to the HTML color name section of this manual):

Add a background color to the first table row:

<table border="1">
<tr bgcolor="#FF0000">
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>

Try it out . . .

Browser support

HTML tr bgcolor attribute HTML tr bgcolor attribute HTML tr bgcolor attribute HTML tr bgcolor attribute HTML tr bgcolor attribute

The bgcolor property is supported by all major browsers.


Definitions and usages

HTML5 does not support the property of slt;tr?gt; bgcolor. Use CSS instead.

In HTML 4.01, the bgcolor property of slt;tr?gt; is discarded.

The bgcolor property specifies the background color of the table row.


Compatibility comments

In HTML 4.01, the bgcolor property of slt;tr?gt; is discarded. Use CSS instead.

CSS syntax: .lt;tr style="background-color:red"

CSS instance: Add a background color to the table row

In our CSS tutorial, you can find more details about the background-color property.


Grammar

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

The property value

value describe
color_name The specified color value is a background color of the color name (such as "red").
hex_number The specified color value is a background color of hexadecimal value (such as "# ff0000").
rgb_number The specified background color (such as "RGB (255, 0, 0)" of the color value is RGB code).


HTML tr bgcolor attribute HTML and tr;tags