我有一个类似这样的部分视图:
@model List<user>
@foreach (var user in Model)
{
<tr>
<td>@user.name</td>
<td>...</td>
</tr>
}
我遇到了以下错误:
验证(HTML5):元素“tr”不能嵌套在元素“tr”中。
这个错误比我想象的更令人烦恼,但我想要摆脱它。安装Web Standards Update没有帮助。有什么想法吗?
编辑 这是主视图:
<table>
<thead>
<tr>
<th>@i18n.name</th>
<th>...</th>
</tr>
</thead>
<tbody id="results">
@Html.Partial("list_rows", @Model.users)
</tbody>
</table>
这是生成的HTML:
<table>
<thead>
<tr>
<th>naam</th>
<th>...</th>
</tr>
</thead>
<tbody id="results">
<tr>
<td>...</td>
<td>...</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
</tr>
</tbody>
</table>
编辑 将整个页面通过 W3C 验证器,结果为
此文档已成功检查为 HTML5!