Re: CSS3 Selectors - :root

Had another look into this after my initial message and yes you are 
right. I think i got a little too excited and realised that because of 
the way the selectors work and are interpreted, the second rule will not 
work. I'll have to blame the lack of caffeine on this one. Thanks for 
your help :)
> ------------------------------------------------------------------------
>
> 	Tab Atkins Jr. <mailto:jackalmage@gmail.com>
> 18 February 2011 1:52 AM
>
>
>
> You seem to slightly misunderstand how Selectors work.
>
> Your first selector example is interpreted as "select all <p> elements
> with a class of 'test' that have the root element as an ancestor".
> This is a perfectly sensical selector.
>
> Your second selector example, though, means "select all <body>
> elements that are descendants of the root element, which is itself a
> descendant of a <p> element with a class of 'test'".
>
> The root element can never be a descendant of anything else in the
> document, by definition. Thus, your second selector will never match
> anything, as ACJ correctly points out.
>
> There is no way in the current Selectors spec to style an element
> based on whether it contains another element, as you want to do.
>
> ~TJ
> ------------------------------------------------------------------------
>
> 	Karl Brightman <mailto:karl@karlbright.org>
> 17 February 2011 11:10 AM
>
>
> Hi,
>
> I have just discovered what I believe to be a bug with the way the 
> :root pseudo class has been implemented.
>
> The specification states the following about this pseudo-class selector:
> /
> "The :root pseudo-class represents an element that is the root of the 
> document. In HTML 4, this is always the HTML element."/
>
> What it does not describe is where the :root can be used, from what I 
> have tried, it only works when used at the beginning of a selector.
>
> /":root p.test { color: red; }"/
>
> However the following does not work:
>
> /"p.test :root body { background: red; }"/
>
> Am i missing something here or is this something that has not yet been 
> addressed? I was hoping to be able to use the :root pseudo class to 
> adjust styled based on whether or not an element can be found within 
> the document.
>
> Regards,
> Karl Brightman
> @karlbright
> karl@karlbright.org

Received on Thursday, 17 February 2011 23:30:08 UTC