浏览器如何分析< tr> < TD>没有< table&gt ;? [英] How do browsers analyze <tr> <td> without <table>?

查看:88
本文介绍了浏览器如何分析< tr> < TD>没有< table&gt ;?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<table border="1">
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
</table>

如果我写这个,浏览器将正常分析。

If I write this, the browser will analyze normally.

<!-- <table border="1"> -->
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>3</td>
            <td>4</td>
        </tr>
    </tbody>
<!-- </table> -->

但是我这样写,我发现浏览器会分析它们而没有任何标签,比如字符串。 p>

But I write like this, I find the browser will analyze them without any tags like string.

<tbody>
    <tr>
        <td>1</td>
        <td>2</td>
    </tr>
    <tr>
        <td>3</td>
        <td>4</td>
    </tr>
</tbody>


$ b $

is the same of

1 2 3 4


推荐答案

浏览器忽略< tbody> < tr> < td> 标签和相应的结束标签。这在HTML规范中没有规定,因为它们没有定义语法错误文档的解析。然而,在HTML5草案中,有一段描述以对应于浏览器实际执行的方式定义浏览器行为:树结构

Browsers ignore the <tbody>, <tr>, and <td> tags and the corresponding end tags. This has not been specified in HTML specifications, since they do not define the parsing of syntactically erroneous documents. In the HTML5 draft, however, there is a description that defines the browser behavior in a manner that corresponds to the what browsers actually do: Tree construction.

这意味着你不能写一个HTML文档包含元素之外的< tr> 元素。浏览器中的HTML解析器根本不会构造这样的文档树。 (但是,您可以使用客户端定制动态地构建这样的文档。)

This means that you cannot write an HTML document that contains, say, a <tr> element outside a table element. The HTML parser in a browser simply does not construct such document trees. (You can, however, construct such a document dynamically with client-side scription.)

这篇关于浏览器如何分析&lt; tr&gt; &LT; TD&GT;没有&lt; table&gt ;?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆