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

Re: [selectors4] Why is the :only-child pseudo-class not a special case in terms of specificity?

From: Benjamin Poulain <benjamin@webkit.org>
Date: Thu, 23 Jul 2015 02:28:44 -0700
Message-ID: <55B0B3CC.9090603@webkit.org>
To: James Donnelly <jdonnelly30@gmail.com>, www-style@w3.org
On 7/14/15 10:23 PM, James Donnelly wrote:
 > In both the Selectors recommendation and the Selectors4 working
 > draft, the :only-child pseudo-class documentation states:
 >> “Same as ‘:first-child:last-child’ or
 >> ‘:nth-child(1):nth-last-child(1)’, but with a lower specificity.”
 > As much as it would go against the basic specificity implementation,
 > wouldn’t it be logical for the :only-child selector to have the same
 > specificity as those combined selectors?

You would create complexity for no good reason.

For any pseudo class without selector argument, the specificity is 
always (0, 1, 0). That's an easy rule to remember (for a concept that is 
already confusing certain developers).

You can still use :first-child:last-child when that specificity makes 
more sense than :only-child in your rules.

Received on Thursday, 23 July 2015 09:30:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:52:18 UTC