HTML <col> 標籤


實例

<colgroup> 和 <col> 標籤為表格中的三個列設置了背景色:

<table border="1">
  <colgroup>
    <col span="2" style="background-color:red">
    <col style="background-color:yellow">
  </colgroup>
  <tr>
    <th>ISBN</th>
    <th>Title</th>
    <th>Price</th>
  </tr>
  <tr>
    <td>3476896</td>
    <td>My first HTML</td>
    <td>$53</td>
  </tr>
</table>


流覽器支持

Internet Explorer Firefox Opera Google Chrome Safari

所有主流流覽器都支持 <col> 標籤。


標籤定義及使用說明

<col> 標籤規定了 <colgroup> 元素內部的每一列的列屬性。

通過使用 <col> 標籤,可以向整個列應用樣式,而不需要重複為每個單元格或每一行設置樣式。


HTML 4.01 與 HTML5之間的差異

HTML5 中不再支持 HTML 4.01 中的大部分屬性。


HTML 與 XHTML 之間的差異

在 HTML 中,<col> 標籤沒有結束標籤。

在 XHTML 中,<col> 標籤必須被正確的關閉。


屬性

屬性 描述
align left
right
center
justify
char
HTML5 不支持。規定與 <col> 元素相關的內容的水準對齊方式。
char character HTML5 不支持。規定根據哪個字元來對齊與 <col> 元素相關的內容。
charoff number HTML5 不支持。規定第一個對齊字元的偏移量。
span number 規定 <col> 元素應該橫跨的列數。
valign top
middle
bottom
baseline
HTML5 不支持。規定與 <col> 元素相關的內容的垂直對齊方式。
width %
pixels
relative_length
HTML5 不支持。Specifies the width of a <col> element


全局屬性

<col> 標籤支持 HTML 的全局屬性


事件屬性

<col> 標籤支持 HTML 的事件屬性