Re: [CSS21] selector's specificity issues.

Hi, Adam.

> The only solution I can see would be to make a new specificity
> ordinal in between case c and case d in the current draft.

That is an ideal solution.
My schema is just an attempt (ugly one actually) to reuse exisitng a,b,c,d

> Can you rephrase in such a way as to be "not difficult to understand"? ...
> Oh, and don't forget about the case of td+td+td (to an arbitrary
> depth)....

Lets imagine that we have N divs and each of them has by itself N child
divs.

<body>

<div 1>
    <div 1>...
    <div N>...
</div>
...
<div N>
    <div 1>...
    <div N>...
</div>

</body>

full number of div elements in the body is N * (1+N)

then
selector "body div" will select all of them - N * (1+N)
selector "body+div" will select nothing - as it is more specific
and selector "body>div" will select N divs - far less as it is also more
specific

In general:
For any given pair of selectors X and Y with nonempty set(X Y)
set(X Y) > set(X+Y)
and
set(X Y) >= set(X>Y)

This means that specificity of X Y and X+Y/X>Y are different for sure.

Andrew Fedoniouk.


From: "Adam Kuehn" <akuehn@nc.rr.com>
> Andrew Fedoniouk wrote:
> >  > Why should ul>li trump li:first-child?
> >
> >From mathematical point of view:
>
> You lost me.  The rule as you proposed it would give ul>li a
> specificity of 0,0,1,2.  You proposed no other changes that I saw, so
> li:first-child would have a specificity of 0,0,1,1 (as it does
> currently).  I.e. ul>li wins.  Similarly, you propose to give td+td a
> specificity of 0,0,1,2.  With no other changes, td.class gets
> 0,0,1,1.  Again, td+td trumps (read: "has a higher specificity than")
> td.class, unless I completely misread your post.
>
> If the rest of your post was trying to explain how to change your
> proposal to get them all to weigh the same, I didn't follow you.  Can
> you rephrase in such a way as to be "not difficult to understand"?
> Oh, and don't forget about the case of td+td+td (to an arbitrary
> depth) which so far as I can see would still need to have a lower
> specificity that td.class to fit with expectations and, indeed,
> current actual usage.
>
> The only solution I can see would be to make a new specificity
> ordinal in between case c and case d in the current draft.  I still
> don't see any compelling reason to do that.  Explain again how the
> benefits outweigh the difficulties?
>
> -- 
>
> -Adam Kuehn
>

Received on Thursday, 8 July 2004 17:55:10 UTC