验证(HTML5):元素’th’不能嵌套在元素’table’中

前端之家收集整理的这篇文章主要介绍了验证(HTML5):元素’th’不能嵌套在元素’table’中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
鉴于以下 HTML,为什么会出现错误

Validation (HTML5): Element ‘th’ cannot be nested in element ‘table’

<table>
    <th>ID</th>
    <th>text header</th>
    <tr>
        <td>7</td>
        <td>text</td>
    </tr>
</table>

解决方法

你不能拥有< th>在< tr>之外的元素,以下代码段有效
<table>
    <tr>
        <th>ID</th>
        <th>text header</th>
    </tr>
    <tr>
        <td>7</td>
        <td>text</td>
    </tr>
</table>

&LT的第i;使用情况上下文https://developer.mozilla.org/en/docs/Web/HTML/Element/th

Permitted parent elements

A <tr>@H_301_21@ element.

原文链接:https://www.f2er.com/html5/168389.html

猜你在找的HTML5相关文章