Latest web development tutorials

HTML td bgcolor attribute

HTML td tag Reference Manual HTML <td> tag

Examples

Add a background color to the cells:

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

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the bgcolor attribute.


Definition and Usage

HTML5 does not support the <td> bgcolor attribute. Use CSS instead.

In HTML 4.01, <td> The bgcolor attribute obsolete .

bgcolor attribute specifies the background color of the table cell.


Compatibility Notes

In HTML 4.01, <td> The bgcolor attribute obsolete. Use CSS instead.

CSS Syntax: <td style = "background-color: red">

CSS Example: to add background color of table cell

In our CSS tutorial you can find more information about the background-color attribute details.


grammar

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

Property Value

描述
color_name 规定颜色值为颜色名称的背景颜色(比如 "red")。
hex_number 规定颜色值为十六进制值的背景颜色(比如 "#ff0000")。
rgb_number 规定颜色值为 rgb 代码的背景颜色(比如 "rgb(255,0,0)")。


HTML td tag Reference Manual HTML <td> tag