浏览器会自动插入哪些DOM元素

浏览器会自动插入哪些DOM元素

本文介绍了浏览器会自动插入哪些DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在生成供客户端使用的XPaths服务器端,我感到困惑的是为什么 only 表路径(即 td

I am generating XPaths server-side for use on the client-side, and I was puzzled as why only table paths (i.e. content in a td) couldn't be found in the DOM.

结果是,现代浏览器(至少是Chrome和Firefox)插入了 tbody 加载文档时在表行周围添加标记。请参见是有效的HTML5,尽管它既没有 head 也没有 body 元素和任何HTML5解析器应该添加它们,以便DOM树看起来像

In SGML/HTML4 terminology some other elements can be inferred, even the head and the body element can be inferred, and HTML5 continues that. So a document like http://home.arcor.de/martin.honnen/html/test2012011901.html is valid HTML5 although it does neither have head nor body element and any HTML5 parser is supposed to add them so the DOM tree looks like

<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<h1>Test</h1>
<p>This is a test.</p>
</body>
</html>

我无法告诉您有关其他元素的所有详细信息,以上仅是示例。在。

I can't tell you all details about other elements, the above is only an example. Look for details in http://www.w3.org/TR/html5/syntax.html#optional-tags.

这篇关于浏览器会自动插入哪些DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 18:40