我总是看到th标签只用在表的第一行.是否有一些特定原因导致它无法用于沿最左侧列创建"左"标题.这是不好的形式,还是这样.
基本上,一个表格在顶行和最左边的列上有标题,最左上方为空.
例如
<table>
<tr>
<th><!--empty--></th>
<th>Top 1</th>
<th>Top 2</th></tr>
<tr>
<th>LeftHeader?</th>
<td>data1</td>
<td>data2</td></tr>
</table>
Run Code Online (Sandbox Code Playgroud)
Ric*_*uen 16
然而,这是有效的,当使用<thead>它必须是第一行.这是有效的:
<table>
<thead>
<tr>
<td>0,0</td><td>1,0</td><td>2,0</td>
</tr>
</thead>
<tr>
<th>0,1</th><th>1,1</th><th>2,1</th>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
但这不是:
<table>
<tr>
<td>0,0</td><td>1,0</td><td>2,0</td>
</tr>
<thead>
<tr>
<th>0,1</th><th>1,1</th><th>2,1</th>
</tr>
</thead>
</table>
Run Code Online (Sandbox Code Playgroud)
这是无效的HTML,您可以使用w3C标记验证服务仔细检查,但在此之前,您必须添加<!DOCTYPE>声明和其他有效的HTML文档.
| 归档时间: |
|
| 查看次数: |
15264 次 |
| 最近记录: |