Re: Computational complexity of CSS

Paul D Stanwyck wrote:
>     p.navbar > a {display: inline; other stuff for all links;}
>     a.hidden {display: none;}

The first selector has higher specificity.  See 
http://www.w3.org/TR/CSS21/cascade.html#specificity -- the first selector has 
specificity 0,0,1,2 while the second has 0,0,1,1

So you could either use "display: none !important" or use "a.hidden.hidden" 
(specificity 0,0,2,1) as the selector, or what you did, or anything else that 
gives you the right specificity ordering.

> It didn't work. My intiution was that the second line would NOT need 
> specifics like "p.navbar >" because of the CSS Rec stating that 
> selectors such as:
>     a[attr]   p.class
> Need only be coded as:
>     [attr]   .class

That part of the CSS specification has nothing to do with the case above.

> Soon enough, I learned that by coding the entire selector specifically:
>     p.navbar > a.hidden {...}

Which incidentally increases its specificity to 0,0,2,2....

-Boris

Received on Thursday, 17 November 2005 23:05:29 UTC