W3C home > Mailing lists > Public > www-style@w3.org > March 2013

[CSS21][css3-selectors] :root in HTML always the HTML element?

From: Øyvind Stenhaug <oyvinds@opera.com>
Date: Wed, 20 Mar 2013 15:01:39 +0100
To: "www-style@w3.org" <www-style@w3.org>
Message-ID: <op.wt8zw1dtbunlto@oyvinds-desktop>
The Selectors spec talks about the "document tree", e.g. "The elements of  
a document tree that are represented by a selector are the subjects of the  
selector." [1]

The definition of this term in CSS 2.1 [2] states that it is a "tree of  
elements" and that "[e]ach element in this tree has exactly one parent,  
with the exception of the root element, which has none."

But for the root pseudo-class [3] it is said "The :root pseudo-class  
represents an element that is the root of the document. In HTML 4, this is  
always the HTML element."

There seems to be an inconsistency here if one considers HTML document  
fragments and HTML elements that are not in a document. I'm assuming that  
such trees are still "document trees" in the CSS sense even though they  
aren't rooted at a Document node in the DOM, since there is still a "tree  
of elements".

In such cases, it seems CSS2 implies that the top-most element (DOM-wise,  
having a DocumentFragment parentNode or a null parentNode) is the "root  
element" in CSS terms, yet it isn't necessarily "the HTML element", which  
css3-selectors claims to be the case.

(See also [4] and thread starting at [5])

[1] http://www.w3.org/TR/css3-selectors/#selector-syntax
[2] http://www.w3.org/TR/CSS21/conform.html#doctree
[3] http://www.w3.org/TR/css3-selectors/#root-pseudo
[4] http://lists.w3.org/Archives/Public/www-style/2007Jun/0116.html
[5] http://lists.w3.org/Archives/Public/www-style/2013Mar/0290.html

Øyvind Stenhaug
Opera Software ASA
Received on Wednesday, 20 March 2013 14:02:12 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:08:27 UTC