HTML bgcolor Attribute
Example
Add 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>
Browser Support
All major browsers support the bgcolor attribute.
Definition and Usage
The bgcolor attribute is not supported in HTML5. Use CSS instead.
In HTML 4.01, the bgcolor attribute for <tr> has been deprecated.
The bgcolor attribute specifies the background color of a table row.
Compatibility Note
In HTML 4.01, the bgcolor attribute for <tr> has been deprecated. Use CSS instead.
CSS syntax: <tr style="background-color:red">
CSS Example: Adding Background Color to Table Rows
You can find more details about the background-color property in our CSS tutorial.
Syntax
<tr bgcolor="color_name|hex_number|rgb_number">
Attribute Values
Value
Description
color_name
Specifies the background color using a color name (e.g., "red").
hex_number
Specifies the background color using a hexadecimal value (e.g., "#ff0000").
rgb_number
Specifies the background color using an RGB code (e.g., "rgb(255,0,0)").
Advertisement
Support us by using these tools:
Byte Ark Coding Plan
Supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax β official supply, stable and reliable.
Β₯9.9 / month
Subscribe Now
Xunfei Xingchen Coding Plan
Includes free model call quotas. Supports DeepSeek, GLM, Kimi, MiniMax β one-stop experience and deployment platform.
Β₯3.9 / month
Subscribe Now
Latest Updates
Site Information
Follow us on WeChat
Example
Add 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>
Browser Support
All major browsers support the bgcolor attribute.
Definition and Usage
The bgcolor attribute is not supported in HTML5. Use CSS instead.
In HTML 4.01, the bgcolor attribute for <tr> has been deprecated.
The bgcolor attribute specifies the background color of a table row.
Compatibility Note
In HTML 4.01, the bgcolor attribute for <tr> has been deprecated. Use CSS instead.
CSS syntax: <tr style="background-color:red">
CSS Example: Adding Background Color to Table Rows
You can find more details about the background-color property in our CSS tutorial.
Syntax
<tr bgcolor="color_name|hex_number|rgb_number">
Attribute Values
| Value | Description |
|---|---|
color_name |
Specifies the background color using a color name (e.g., "red"). |
hex_number |
Specifies the background color using a hexadecimal value (e.g., "#ff0000"). |
rgb_number |
Specifies the background color using an RGB code (e.g., "rgb(255,0,0)"). |
Advertisement
Support us by using these tools:
Byte Ark Coding Plan
Supports mainstream large models like Doubao, GLM, DeepSeek, Kimi, MiniMax β official supply, stable and reliable.
Β₯9.9 / month
Subscribe NowXunfei Xingchen Coding Plan
Includes free model call quotas. Supports DeepSeek, GLM, Kimi, MiniMax β one-stop experience and deployment platform.
Β₯3.9 / month
Subscribe NowLatest Updates
Site Information
Follow us on WeChat
YouTip