HTML <table> 標籤的 bgcolor 屬性

實例

帶有背景顏色的 HTML 表格:

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

定義和用法

bgcolor 屬性規定規定表格的背景顏色。

相容性註釋

在 HTML 4.01 中,不贊成使用 body 元素的 bgcolor 屬性;在 XHTML 1.0 Strict DTD 中,不支援 body 元素的 bgcolor 屬性。

請使用 CSS 代替。

CSS 語法:<table style="background-color:red">

CSS 實例:表格背景顏色

在我們的 CSS 教程中,您可以找到更多有關 background-color 屬性的細節。

語法

<body bgcolor="value">

屬性值

描述
color_name 規定顏色值為顏色名稱的背景顏色(比如 "red")。
hex_number 規定顏色值為十六進制值的背景顏色(比如 "#ff0000")。
rgb_number 規定顏色值為 rgb 程式碼的背景顏色(比如 "rgb(255,0,0)")。