Html中的table包括 caption、col、colgroup、thead、tfoot 以及 tbody

HTML <table> 標籤

定義和用法

<table> 標籤訂義 HTML 表格。spa

簡單的 HTML 表格由 table 元素以及一個或多個 tr、th 或 td 元素組成。code

tr 元素定義表格行,th 元素定義表頭,td 元素定義表格單元。it

更復雜的 HTML 表格也可能包括 caption、col、colgroup、thead、tfoot 以及 tbody 元素。io

其實就使用來講table,tr,td。就夠了。正規點加個表頭,就是table, tr,th,td。若是包含標題,就在用上captiontable

第二種就是table,thead,tbody,tfoot,tr ,th,td一塊兒來使用,對錶進行分組。樣式

再複雜些就的使用col,colgroup了。tab

HTML <col> 標籤

定義和用法

<col> 標籤爲表格中一個或多個列定義屬性值。標籤

如需對所有列應用樣式,<col> 標籤頗有用,這樣就不須要對各個單元和各行重複應用樣式了。co

您只能在 table 或 colgroup 元素中使用 <col> 標籤。ab

實例

col 元素爲表格中的三個列規定了不一樣的對齊方式:

<table width="100%" border="1">
  
  
  
  <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><col align="left" /><col align="left" /><col align="right" />

HTML <colgroup> 標籤

定義和用法

<colgroup> 標籤用於對錶格中的列進行組合,以便對其進行格式化。

如需對所有列應用樣式,<colgroup> 標籤頗有用,這樣就不須要對各個單元和各行重複應用樣式了。

<colgroup> 標籤只能在 table 元素中使用。

實例

兩個 colgroup 元素爲表格中的三列規定了不一樣的對齊方式和樣式(注意第一個 colgroup 元素橫跨兩列):

<table width="100%" border="1">
  <colgroup span="2" align="left"></colgroup>
  <colgroup align="right" style="color:#0000FF;"></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>

就實用來講建議table,tr,td來用。比較簡單。也不容易出錯。就正規來講table ,thead,tbody,tfoot,tr ,th,td來用也就能夠了。

特別狀況纔會使用col,colgroup。

相關文章
相關標籤/搜索