W3C home > Mailing lists > Public > www-style@w3.org > September 2011

Re: [css3-selectors] Should pseudo-classes "of type" discriminate based on class selectors?

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 15 Sep 2011 08:06:05 -0700
Message-ID: <CAAWBYDCPoES1u4zcW9JDBFpzdDXHteQEhqkwGs8bzejDtZGU9A@mail.gmail.com>
To: "Linss, Peter" <peter.linss@hp.com>
Cc: Eric Peterson <i.am@eric.pe>, "www-style@w3.org" <www-style@w3.org>
On Thu, Sep 15, 2011 at 3:21 AM, Linss, Peter <peter.linss@hp.com> wrote:
> On Sep 12, 2011, at 12:11 PM, Eric Peterson wrote:
>> I think it makes sense for CSS3 pseudo-classes ending with "-of-type" (i.e. nth-of-type, only-of-type, first-of-type, etc.) ought to take into account not only their  elements, but also any class selectors attached to the element.
>> i.e.
>> div > p:nth-of-type(2) {}
>> Would affect the second p directly descendant of div.  While on the other hand...
>> div > p.foo:nth-of-type(2) {}
>> Would affect only the second p with class "foo" directly descendant of div.
> Currently that means the second p child of div, if it has the class 'foo'. How would you get that behavior with your proposal?
> Having:
> div > p:nth-of-type(2).foo {} be different from:
> div > p.foo:nth-of-type(2) {} is a possibility but order has historically not been significant within a simple selector and adding that now could be problematic.
> It would likely be better to simply add p:nth-of-class(foo, 2) or something like :nth-of(p.foo.bar:visited, 2)

Agreed with Peter.  Order within a compound selector has never
mattered before (with the exception of pseudo-elements, which pretend
that they don't have a combinator), and I don't think we should break
that now.  If you *don't* have ordering matter, then this actually
precludes many useful selectors.

An :nth-of() pseudo would be ideal.

Received on Thursday, 15 September 2011 15:06:56 UTC

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:04 UTC