我有这样的局部 View :
@model List<user>
@foreach (var user in Model)
{
<tr>
<td>@user.name</td>
<td>...</td>
</tr>
}
并得到这样的错误:
Validation (HTML5): Element 'tr' cannot be nested within element '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 验证器拉取整个页面给出
This document was successfully checked as HTML5!
最佳答案
打开 <tr>
时会出现此错误在循环模型之前添加元素。到目前为止,您发布的代码是正确的,没有错误。
关于visual-studio-2010 - 元素 'tr' 不能嵌套在元素 'tr' 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9785012/