在 <th> 元素内添加 <th> 元素

Myx*_*tic 2 html html-table

我有一个 html 表格,其中一个标题跨越 2 列。如何向两列中的每一列添加子标题?

例如,在附图中,我希望“联系人”列的相应列有子标题“电话”和“地址”。

在此输入图像描述

Nie*_*sol 5

与在纸上绘制表格的方式相同:

<table>
  <thead>
    <tr>
      <th rowspan="2">Name</th>
      <th rowspan="2">Email</th>
      <th colspan="2">Contact</th>
    </tr>
    <tr>
      <th>Phone</th>
      <th>Address</th>
    </tr>
  </thead>
  <tbody>
    <!-- your data goes here -->
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)