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。

相关文章
相关标签/搜索