HTML元素分類-表格元素
0. <table>:定義表格。
<caption>:定義表格標題。caption 元素緊隨 table 元素之后,每個表格只能
定義一個標題,標題居中于表格之上。
<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>:定義表格的表頭。該元素用于組合表格的表頭內容。
<tbody>:用于對表格中的主體內容進行分組。
<tfoot>:用于對表格中的表注(頁腳)內容進行分組。
<tr>:定義表格中的行。
<th>:定義表格內的表頭單元格。
<td>:定義表格中的標準單元格。
<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>:組合表格中的列,對其進行格式化。只能在 table 元素中使用。
<col>:為表格中一個或多個列定義屬性值。只能在 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元素內所有的子元素之前。
【 微信掃一掃 】