validation - 页脚不验证 xhtml?

标签 validation xhtml xhtml-transitional

在添加此表之前,我已针对 xhtml 过渡验证了我的网页(见下文)。从那时起它就不会验证并说“

document type does not allow element "tfoot" here <tfoot>

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error)."

对正在发生的事情有什么想法吗?我检查了任何打开和未关闭的标签,但没有找到任何标签,所以我不知道还有什么问题。

<table>
<caption>
My first table, Anna
</caption>
<thead>
<tr>
<th>
June
</th>
<th>
July
</th>
<th>
August
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
 Data 1
</td>
<td>
Data 2
</td>
<td>
 Data 3
</td>
<td>
Data 4
 </td>
 </tr>
 <tr>
 <td>
   Data a
  </td>
   <td>
 Date b
</td>
<td>
Data c
</td>
<td>
Data d
</td>
</tr>
<tfoot>
<tr>
<td>
Result1
</td>
</tr>
</tfoot>
</tbody>
</table>

最佳答案

你有 <tfoot>在 table 的尽头。它应该在 <thead> 之间和 <tbody> .它会出现在底部,但编码在顶部。最初的想法之一是,当加载一个大表格时,标题和页脚将很快可见,其余部分将被填充(尤其是当正文在它们之间滚动时很有用)。它在实践中并没有完全像那样,但如果你知道它确实更有意义。

DTD它列出:

<!ELEMENT table (caption?, (col*|colgroup*), thead?, tfoot?, (tbody+|tr+))>

即可选caption , 然后零个或多个 colcolgroup , 然后可选 thead , 然后可选 tfoot , 那么至少有一个 tbodytr .

更新:请注意,HTML 5 现在允许将 <tfoot>在表的末尾,而不是在第一个 <tbody> 之前(或第一个 <tr> 不在 <thead><tfoot><tbody> 中,因此在单个隐式 <tbody> 中)。因此,问题中的代码现在将被视为有效。旧方法也仍然有效,并且可能是可取的。

关于validation - 页脚不验证 xhtml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3503503/

相关文章:

css - 3 个固定列(页眉和页脚)使用 DIV,没有绝对 DIV,IE 友好,所有列均等拉伸(stretch)

validation - SONARQUBE - 项目验证失败,%project 已经是项目的一部分

html - 设置 Bootstrap 中复选框所需的属性

java - Spring 验证: Difference between validation annotations in Class Attributes VS Constructor Parameters

python - 验证值仍然导致类型错误?

html - HTML 中的日期时间是什么?

html - 手机浏览器上的accesskey

php - 我如何获取 ?> 和 <?php 之间的内容

css - 对齐中心搞乱定义列表

html - <div> 在 <a> 中