W3C home > Mailing lists > Public > www-style@w3.org > November 2000

Re: pseudo-elements and *

From: Matthew Brealey <webmaster@richinstyle.com>
Date: 6 Nov 2000 11:09:19 -0000
Message-ID: <20001106110919.8768.qmail@phoenix.futurequest.net>
To: www-style@w3.org
You wrote:
> 
> fantasai wrote:
> 
> > Does the universal selector (*) apply to pseudo-elements?
> > 
> > example - given the following
> > 
> > p::first-line {color: red}
> > * {color: black !important}
> > 
> > Will the first line of each <p> be red or black?
> 
> 
> Eeehhhh. Perhaps a very good catch... According to cascading
> order (section 6.4.1 of the spec), the color of each P should
> be black, even if the first rule has a more specific selector.

Yes, but * 'matches any single element in the document tree.'

Pseudo-elements, by definition, aren't in the document tree, so there 
is no conflict.

So given:

<p>
text

the P is matched, because it is in the document tree. This inherits 
into the *pseudo-*element. There is no question of specificity because 
only :first-line matches that pseudo, and it is quite simple that 
children always override inheritance.

> By the way,  the two following rules should also make the first line
> black, according to cascading order and specificity 
> computation rules :
> 
> P::first-line { color :red }
> P { color : black }

Pseudo-elements wouldn't work at all if this was the case - they rely 
on the fact that they inherit their parent's style (just as 
P {color: black}
DIV {color: red}
<div>
<p>
text
</div>
makes P black)

, rather than conflict with them.
-- Random fortune
Q:	Why don't lawyers go to the beach?
A:	The cats keep trying to bury them.
Received on Monday, 6 November 2000 06:09:59 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:06 GMT