Re: pseudo-elements and *

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 UTC