W3C home > Mailing lists > Public > www-style@w3.org > July 2004

Re: [CSS21] selector's specificity issues.

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Thu, 8 Jul 2004 09:20:00 -0700
Message-ID: <001c01c46507$6b7199c0$0401a8c0@ATHLON>
To: <www-style@w3.org>, "Adam Kuehn" <akuehn@nc.rr.com>

> It is arguably more specific, but is the difference enough to make it
> worth complicating the specificity hierarchy?  Right now, specificity
> depends roughly on a) style attribute vs. element, b) IDs, c)
> classes, d) everything else.  Where in that hierarchy would you place
> this difference?  Why do you think the added complication would be
> worth the addition?

My solution is pretty simple.

If we will update second specificity rule:

1) count the number of ID attributes in the selector (= b)
2) count the number of other attributes and pseudo-classes in the selector
(= c)
   *plus number of  '>' and '+' in the selector*
3) count the number of element names and pseudo-elements in the selector (=
d)

Then we will have:

case "UL LI":
   d = 2

case "UL>LI":
   c = 1
   d = 2

I don't think that it is difficult to implement and to understand.

Andrew Fedoniouk.


From: "Adam Kuehn" <akuehn@nc.rr.com>
>
> Andrew Fedoniouk wrote:
>
> >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.
>
> It is arguably more specific, but is the difference enough to make it
> worth complicating the specificity hierarchy?  Right now, specificity
> depends roughly on a) style attribute vs. element, b) IDs, c)
> classes, d) everything else.  Where in that hierarchy would you place
> this difference?  Why do you think the added complication would be
> worth the addition?
>
> Sure, a child selector is logically more specific than a descendent
> selector.  Arguably, so is an adjacent sibling selector.  And the
> selector e[foo="bar"] is more specific than e[foo].  But is noting
> those differences worth the cost in user overhead in remembering
> those differences?
>
> Personally, I'd say, "No."
>
> --
>
> -Adam Kuehn
>
Received on Thursday, 8 July 2004 12:20:30 GMT

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