为什么内部 TABLE 部分必须经过 THEAD TFOOT TBODY 才能验证?
我经常使用 THEAD、TBODY 和 TFOOT 元素将数据表划分为可以使用 CSS 单独寻址的部分。我也明白总是有一个隐式的 TBODY 标签。
让我困惑的是这些必须进入验证的顺序。此表将验证:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table Validation Test</title>
</head>
<body>
<table>
<thead>
<tr>
<th scope="col">Enemies List</th>
</tr>
</thead>
<tfoot>
<tr>
<td>© Bomb Voyage</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Mr. Incredible</td>
<td>Elastigirl</td>
<td>Gazer Beam</td>
</tr>
</tbody>
</table>
</body>
</html>
但此表不会:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table Validation Test</title>
</head>
<body>
<table>
<thead>
<tr>
<th scope="col">Enemies List</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mr. Incredible</td>
<td>Elastigirl</td>
<td>Gazer Beam</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>© Bomb Voyage</td>
</tr>
</tfoot>
</table>
</body>
</html>
有效的表为 HEAD、FOOT、BODY;这没有任何意义。
将脚放在桌子底部可以保持桌子与人体之间的类比。但由于某种原因,这个命令被认为是无效的。
有人知道为什么吗?
I often use THEAD, TBODY, and TFOOT elements to divide my data tables into sections that can be addressed separately with CSS. I also understand that there is always an implicit TBODY tag.
What puzzles me is the order that these have to go in to validate. THIS table will validate:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table Validation Test</title>
</head>
<body>
<table>
<thead>
<tr>
<th scope="col">Enemies List</th>
</tr>
</thead>
<tfoot>
<tr>
<td>© Bomb Voyage</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Mr. Incredible</td>
<td>Elastigirl</td>
<td>Gazer Beam</td>
</tr>
</tbody>
</table>
</body>
</html>
But this one will not:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Table Validation Test</title>
</head>
<body>
<table>
<thead>
<tr>
<th scope="col">Enemies List</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mr. Incredible</td>
<td>Elastigirl</td>
<td>Gazer Beam</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>© Bomb Voyage</td>
</tr>
</tfoot>
</table>
</body>
</html>
The valid one goes HEAD, FOOT, BODY; which does not make any sense.
Putting the foot at the bottom of the table would maintain the analogy between the table and a human body. But for some reason, this order is considered invalid.
Anyone know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
规范给出了一个原因:
http://www.w3.org/TR/html401/struct/tables。 html#h-11.2.3
我不知道是否有浏览器实际上遵循这种行为,并且在 HTML5 中对其进行了更改以处理 HTML 4 顺序和更逻辑的顺序:
http://www.w3.org/TR/html5/tabular-data.html
The spec provides a reason:
http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3
I don't know if any browsers actually follow this behavior, and it was changed in HTML5 to handle both the HTML 4 order and the more logical order:
http://www.w3.org/TR/html5/tabular-data.html