< tbody>标签显示为chrome,但不显示来源 [英] <tbody> tag displays in chrome but not source

查看:67
本文介绍了< tbody>标签显示为chrome,但不显示来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行一些抓取工作时,我经常遇到Chrome DevTools检查器中的< tbody> 标记,但该标记未出现在源代码中.由于我希望有明显的原因,我觉得这很令人困惑.这里发生了什么?(我还应该补充一点,此页面上的html格式有误).

In doing some scraping work I keep encountering the <tbody> tag in the Chrome DevTools inspector, but it doesn't appear in the source. For what I hope are obvious reasons, I find this super confusing. What's going on here? (I should also add that the html on this page is pretty malformed).

例如,DevTools显示:

For example, DevTools shows:

<table>
    <tbody>
        <tr valign="top">
            <td>...</td>

页面来源显示:

<table border="0">
    <tr valign="top">
        <td>

推荐答案

< tbody> 的开始标记是可选的.也就是说,您可以将其省略,但是在需要时浏览器会自动将其插入.

The start tag for <tbody> is optional. That is, you can leave it out, but it is automatically inserted by the browser whenever needed.

这是 所必需的,因为规则说您不能直接在 table 中有一个 tr . table 元素的唯一子元素可以是 caption colgroup thead tbody tfoot .
因此,如果浏览器在 tbody 外部遇到 tr ,则会插入 tbody tr 将驻留在其中

And it is needed, because the rules say you can't have a tr directly in a table. The only children of a table element can be caption, colgroup, thead, tbody and tfoot.
So, if the browser encounters a tr outside a tbody, it inserts a tbody which the tr will reside in.

有关更正式的说法,请参见 http://www.w3.org/TR/html-markup/tbody.html

For a more formal way of saying this, see http://www.w3.org/TR/html-markup/tbody.html

顺便说一句,其他开始标记也是如此,例如< body> .如果您在</head> 之后直接写一个< h1> ,浏览器将在其中插入一个隐含的< body>.自动.

By the way, the very same happens with other start tags, like <body>. If you omit that, writin, say, a <h1> directly after the </head>, the browser will insert an implied <body> automatically.

这篇关于&lt; tbody&gt;标签显示为chrome,但不显示来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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