Re: [CSS21] selector's specificity issues.

At 01:39 AM 7/8/2004, Lachlan Hunt digitized these thoughts:
>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.
>
>No, they have the same specificity.  Where in the spec does it say 
>otherwise?

I believe Andrew's point was that the current algorithm would assign 
the two selectors the same specificity even though, logically, the 
child selector /should/ be more specific than the descendent selector.

I agree that the specificity algorithm leaves a bit to be desired. 
Another illustration I've used is "#foo div" vs. "div #bar". 
Intuitively, the latter selector is more specific than the former -- it 
can only ever match a single element in a document, where the former 
can match any number of elements.

However, I can't think of any good way to account for cases like that 
without making the algorithm much more complex, which would be even 
more difficult for developers to wrap their brain around and for 
implementors to get right.

--
Porter Glendinning     mailto:porter@cerebellion.com
Web Commando                      http://www.g9g.org

Received on Thursday, 8 July 2004 11:15:27 UTC