Web前端技术 · 第3课 5 / 25 | 编码:L03-08a
HTML5中的表格

第三步:给表格命名,并组织各行

数据保持不变,加入表题、行分组和一行汇总。

<table>
  <caption>前两次理论课的学时</caption>
  <thead>
    <tr>
      <th>主题</th>
      <th>学时</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th>网页设计基础</th>
      <td>2</td>
    </tr>
    <tr>
      <th>初识HTML5</th>
      <td>2</td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
      <th>合计</th>
      <td>4</td>
    </tr>
  </tfoot>
</table>

行分组内部仍是tr,再由tr包含th或td。合计4是手动填写的,tfoot不会自动求和;这些元素也不负责自动画边框。