W3C home > Mailing lists > Public > www-style@w3.org > October 2014

Re: [selectors] Specificity of :nth-child() and :nth-last-child() with a selector list

From: L. David Baron <dbaron@dbaron.org>
Date: Fri, 31 Oct 2014 12:51:48 -0700
To: Benjamin Poulain <bpoulain@apple.com>
Cc: www-style list <www-style@w3.org>
Message-ID: <20141031195148.GA30902@crum.dbaron.org>
On Friday 2014-10-31 12:38 -0700, Benjamin Poulain wrote:
> Currently, :nth-child(An+B of selector) has the same specificity has :nth-child() (0, 1, 0).
> 
> Given the new definition of :nth-child(An+B of selector) must match selector on the current element, I believe it would make sense to include the specificity of the nested selector in the specificity of :nth-child() and :nth-last-child().
> 
> For example:
> 	:nth-child(odd of #WebKit)
> would have (1, 1, 0).

It largely seems reasonable to me.  Presumably it would work like
the specificity of :matches() as described in
http://dev.w3.org/csswg/selectors/#specificity

Though it's a little bit interesting that:

  :nth-child(odd of p, .byline)

would have specificity (0, 2, 0) for the #byline and (0, 1, 1) for
the p.  I guess that's probably ok, though.

-David


-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Received on Friday, 31 October 2014 19:52:13 UTC

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