W3C home > Mailing lists > Public > www-style@w3.org > March 2010

Re: [css3] Specificity mechanism issue

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 30 Mar 2010 22:27:04 -0400
Message-ID: <4BB2B2F8.9010807@mit.edu>
To: "Jens O. Meiert" <jens@meiert.com>
CC: www-style@w3.org
On 3/30/10 9:28 PM, Jens O. Meiert wrote:
> In CSS 1, the selector “a b c d e f g h i j” has the specificity 10,
> same as “.a” [2].

No, it doesn't.

> In CSS 2, the selector “a b c d e f g h i j” has the specificity 10,
> same as “.a” [3].

Again, no.

> In CSS 2.1, the selector “a b c d e f g h i j” has the specificity
> 0,0,0,10, less specific than “.a” which has 0,0,1,0 [4].

Not quite.  In CSS2.1 you still do the concatenating thing, no?

> In CSS 3, the selector “a b c d e f g h i j” has the specificity 10,
> same as “.a” [5].

No.

> (I don’t understand that when the specs are talking about
> concatenation, there would be a difference between “a b c d e f g h i
> j”’s 10 and “.a”’s 10. Please correct me if I’m wrong, and if I am,
> let’s maybe make things more clear in the specs.)

You're wrong because the concatenation includes all the counts involved. 
  So for the "a b c d e f g h i j" case you concatenate a 0 (for IDs), 0 
(for classes), and 10 (for the tags).  For ".a" you concatenate a 0, 10, 
and 0.

Done in base 16, for example, you get 00A and 0A0 respectively.  These 
are quite different, and the latter is bigger.

I personally think that the "large base" thing is not worth the 
confusion it engenders and the specificity should just be an ordered 
4-tuple of natural numbers, with the 4-tuples ordered in a dictionary 
ordering.  The spec would probably need to explain the dictionary 
ordering thing, but it would be less confusing than the concatenation stuff.

I'll note that the example specificities given in CSS2.1 are already 
given as 4-tuples, which is what might have confused Jens into thinking 
the specificity is a 4-tuple in CSS2.1.

-Boris
Received on Wednesday, 31 March 2010 02:27:40 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:25 GMT