Re: [css3-selectors] No way to select preceding sibling element

On Mon, Jul 13, 2009 at 7:59 PM, Tab Atkins Jr.<jackalmage@gmail.com> wrote:
> As an addendum to my previous email, I'll note that we have some
> selectors in CSS that are just as bad as some of the reverse
> combinators.  :last-of-type, for example, is essentially equivalent to
> a reverse ~ ("p:last-of-type" and "p [reverse~] p" are identical in
> effect).

No, they aren't, AFAICT.  In <div><p>a<p>b<p>c</div>, p:last-of-type
matches only the final p, while p ~~ p (using ~~ for [reverse~] for
readability) matches the first two.  p:last-of-type is the same as
p:not(p ~~ p).

In principle :last-of-type (and :only-child, etc.) could require that
the whole page's style be recomputed.  E.g., you could have

<body>
<div>...whole page...</div>
<div>Minor footer nobody cares about</div>
</body>

and body > :only-child, or body > :last-of-type, or whatever.  But
they're narrower and so likely to be used less, I guess.  Plus they're
essential for some styling.

Received on Tuesday, 14 July 2009 00:39:02 UTC