HTML元素分類-表格元素
0. <table>:定義表格。
<caption>:定義表格標(biāo)題。caption 元素緊隨 table 元素之后,每個(gè)表格只能
定義一個(gè)標(biāo)題,標(biāo)題居中于表格之上。
<table border="1">
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
</table>
<thead>:定義表格的表頭。該元素用于組合表格的表頭內(nèi)容。
<tbody>:用于對(duì)表格中的主體內(nèi)容進(jìn)行分組。
<tfoot>:用于對(duì)表格中的表注(頁腳)內(nèi)容進(jìn)行分組。
<tr>:定義表格中的行。
<th>:定義表格內(nèi)的表頭單元格。
<td>:定義表格中的標(biāo)準(zhǔn)單元格。
<table border="1">
<thead>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
</thead>
<tbody>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Sum</td>
<td>$180</td>
</tr>
</tfoot>
</table>
<colgroup>:組合表格中的列,對(duì)其進(jìn)行格式化。只能在 table 元素中使用。
<col>:為表格中一個(gè)或多個(gè)列定義屬性值。只能在 table 或 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>
這里需要注意的是,在H5中,col元素、colgroup元素僅支持屬性span且必須被嵌套在
table元素內(nèi)所有的子元素之前。
【 微信掃一掃 】