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

Re: Specificity: nth-of-type versus attribute selector?

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Sun, 4 Jul 2010 15:57:45 -0400
Message-ID: <AANLkTinzsMG2dvv1LEV8Zrp2fPWn1ea-oSRa56AUcS_B@mail.gmail.com>
To: Estelle Weyl <estelle@weyl.org>
Cc: Anton Prowse <prowse@moonhenge.net>, www-style@w3.org, "L. David Baron" <dbaron@dbaron.org>
On Sun, Jul 4, 2010 at 3:49 PM, Estelle Weyl <estelle@weyl.org> wrote:
> This issue I am having, however, is not with the :not or the :nth-of-type,
> it is with the selection order or process.

There is no ordering.  The meaning is the same whether you apply
:nth-of-type first, or the attribute selector first.  :nth-of-type
selects the nth element with a particular *element name*.  It will
select the nth <img>, or the nth <div>, or the nth <fooziblatz>
element.  It does not select "the nth element matching the rest of the
selector", or anything else.  Look at the definition in the spec:

"The :nth-of-type(an+b) pseudo-class notation represents an element
that has an+b-1 siblings with the same expanded element name before it
in the document tree, for any zero or positive integer value of n, and
has a parent element."

Note "with the same expanded element name".  Element names only, nothing else.

> I am looking for
> Of the image that have src*=photo, match the odd ones.

This is not doable with Selectors Level 3, as far as I can tell.

> Is this a correct browser rendering according to the specificiations?


> I
> there a way to return first the attribute selector portion, then apply the
> nth-of-type pseudo class on top of that?

Logically, yes.  That's what you're doing.  It returns exactly the
same result as if you applied the selectors in the opposite direction,
however, because nth-of-type does not mean what you seem to think it
Received on Sunday, 4 July 2010 19:58:18 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:37 UTC