在表格内但在td之外有一个元素

时间:2012-11-21 17:12:15

标签: html css

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

例如:

<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 个答案:

答案 0 :(得分:2)

是的,把它放在桌子外面或在牢房内。

答案 1 :(得分: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).

答案 2 :(得分:0)

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

答案 3 :(得分:0)

是的,它会提供验证错误,因为在像TABLE元素内部不允许的情况下找不到A元素。