Re: [CSS21] selector's specificity issues.

Andrew Fedoniouk wrote:
> #1 -----------------------------------------------------------------
> 
> Algortihm described in [1] for counting style selector's specificity
> does not distinguish cases:
> 
> "ul li" and "ul>li"
> 
> Obviously second case is more strong/specific therefore it should have a
> bigger weight.
> 
> [1] http://www.w3.org/TR/CSS21/cascade.html#specificity

Considering that the spec says: "count the number of other 
attributes and pseudo-classes in the selector (= c)" and then states 
that "In particular, a selector of the form "[id=p33]" is counted as 
an attribute selector (a=0, b=0, c=1, d=0)" even though attribute 
selector isn't listed for 'c', I'd think that '>' selector should 
have similar specificity (that is, c=1) because it isn't element 
name or pseudo-element (which would make it d=1).

It would be real nice if table in Selectors - Pattern Matching 
<URL:http://www.w3.org/TR/CSS21/selector.html#q1> contained 
specificity for each selector because the table has selectors such 
as "*", "#id" and ">" which all get different specificity.

I think "ul>li" is logically much more specific than "ul li" and it 
count so.

> #2 -----------------------------------------------------------------
> 
> CSS grammar and lexical rules [2] do not define "*" asterisk (as an
> indentifier) at all.
> Or I am wrong here?
> [2] http://www.w3.org/TR/CSS21/grammar.html#q1

Well, it does have

selector
   : simple_selector [ combinator simple_selector ]*
   ;
simple_selector
   : element_name [ HASH | class | attrib | pseudo ]*
   | [ HASH | class | attrib | pseudo ]+
   ;
element_name
   : IDENT | '*'
   ;
             ^^^^
Looks okay to me.

-- 
Mikko

Received on Thursday, 8 July 2004 09:11:55 UTC