4
For the purposes of using CSS with HTML, whether you call it a document tree or a DOM tree doesn't make much of a difference. As an author working with HTML and CSS, all you need to know is that the tree is the structure of elements as marked up in the HTML.
为了将CSS与HTML结合使用,无论是将其称为文档树还是DOM树,都没有太大区别。作为使用HTML和CSS的作者,您需要知道的是树是HTML中标记的元素结构。
The DOM, short for Document Object Model, is a set of APIs through which elements of an HTML or XML document can be accessed and modified. Strictly speaking, the DOM, in itself, is not the document tree (or a document tree for that matter), but an interface to said tree (although the tree itself can be implemented according to the DOM). See What is the Document Object Model? in the DOM spec for a lengthy explanation.
DOM是文档对象模型的缩写,是一组API,通过它可以访问和修改HTML或XML文档的元素。严格来说,DOM本身不是文档树(或文档树),而是所述树的接口(尽管树本身可以根据DOM实现)。请参阅什么是文档对象模型?在DOM规范中进行了长时间的解释。
Furthermore, a document tree may not necessarily be represented or interfaced with by the DOM, since CSS may be used to style things other than HTML or XML DOM trees. The DOM provides just one implementation of the concept of a "document tree". This is why the Selectors spec (and related specs) never refer to the document tree as "the DOM" or "the DOM tree", except when specifically referring to the DOM standard.
此外,文档树可能不一定由DOM表示或接口,因为CSS可用于对除HTML或XML DOM树之外的事物进行样式化。 DOM仅提供“文档树”概念的一种实现。这就是选择器规范(和相关规范)从未将文档树称为“DOM”或“DOM树”的原因,除非专门引用DOM标准。
The definition of a "document tree" according to CSS, then, can be found in the CSS2.1 spec:
那么,根据CSS的“文档树”的定义可以在CSS2.1规范中找到:
Document tree
The tree of elements encoded in the source document. Each element in this tree has exactly one parent, with the exception of the root element, which has none.
文档树源文档中编码的元素树。此树中的每个元素只有一个父元素,但根元素除外,它没有。
When the source document language is HTML or XML, and the implementation used is the DOM, the resulting document tree is a DOM tree.
当源文档语言是HTML或XML,并且使用的实现是DOM时,生成的文档树是DOM树。