0

在表格标签内但在单元格之外有一个元素是不好的做法还是出于任何原因不合理?

例如:

<table>
    <tbody>
        <td>Hello,</td>
        <td>Help me I'm a table cell.</td>
        <td>I'm just happy to be here.</td>
    </tbody>
    <a>close button</a>
</table>
4

4 回答 4

2

是的,把它放在桌子外面或单元格内。

于 2012-11-21T17:13:34.413 回答
1

如果您想检查有效的 HTML http://validator.w3.org/check ,请使用它。它将显示以下错误:

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).
于 2012-11-21T17:22:38.873 回答
0

是的,它会提供一个验证错误,因为 A 元素无法在不允许的上下文中找到,例如在 TABLE 元素中。

于 2012-11-21T17:29:14.247 回答
0

是的。<a>不允许直接在 a 内<table>。将其放在单元格(<td><th>)内或表格外。您也可以使用<caption>.

于 2012-11-21T17:15:15.493 回答