At 08:36 +0000 on 10/13/2008, Bobby Jack wrote about Re: [css-d] 
declaration specificity - less-specific line ov:

>  > On Oct 12, 2008, at 11:25 AM, Erik Harris wrote:
>>
>>  > I've got a <ul> element buried with this
>>  hierarchy:
>>  > ....div#sidebar > ul > li#pages > ul
>>  >
>>  > I've got the following two lines in my stylesheet:
>>  >
>>  > #sidebar ul ul {margin: 5px 0 0 10px;}
>>  > #pages ul {margin: 0em; padding: 0em;}
>>  >
>>  > Despite the fact that it seems that the second line
>>  should be more
>>  > specific (#pages is more specific because it's
>>  deeper in the 
>>  > hierarchy),
>
>--- On Sun, 10/12/08, Philippe Wittenbergh <[EMAIL PROTECTED]> wrote:
>
>>  #sidebar ul ul : a=1 b=0 c=2 --> 102
>>  #pages ul a=1 b=0 c=1 --> 101
>>
>  > http://www.w3.org/TR/css3-selectors/#specificity
>
>Just to expand on Philippe's brief (although totally correct) explanation:
>
>CSS does not take hierarchy into account when calculating 
>specificity, however illogical that might seem. The first rule 
>'wins' merely because of the additional 'ul'. You could rewrite that 
>second selector "#sidebar #pages ul" to resolve this issue.

This change "wins" because it scores 201 (2 IDs). The problem with 
the scoring (as you note) is that if the first had one one ul, both 
would score 101 and hierarchy in theory need to come into play to 
select. If I remember correctly, the order of encounter of the rules 
is what ends up getting used as the tie-breaker in the case of 
duplicate scores (ie: Either the first or last winning rule). A 
better method (at least for tie-breaking if not specificity) is to 
use the hierarchy (ie: Which one is included in the range covered by 
the other as if they were nested SPANs).

>
>- Bobby
>
>
>      
>______________________________________________________________________
>css-discuss [EMAIL PROTECTED]
>http://www.css-discuss.org/mailman/listinfo/css-d
>List wiki/FAQ -- http://css-discuss.incutio.com/
>List policies -- http://css-discuss.org/policies.html
>Supported by evolt.org -- http://www.evolt.org/help_support_evolt/


-- 

Bob Rosenberg
RockMUG Webmaster
[EMAIL PROTECTED]
www.RockMUG.org
______________________________________________________________________
css-discuss [EMAIL PROTECTED]
http://www.css-discuss.org/mailman/listinfo/css-d
List wiki/FAQ -- http://css-discuss.incutio.com/
List policies -- http://css-discuss.org/policies.html
Supported by evolt.org -- http://www.evolt.org/help_support_evolt/

Reply via email to