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

Increasing specificity through pseudo-class repetition

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Tue, 14 Jul 2009 18:36:13 +0000
To: "www-style@w3.org" <www-style@w3.org>
Message-ID: <045A765940533D4CA4933A4A7E32597E020C2692@TK5EX14MBXC111.redmond.corp.microsoft.com>
Should repeated instances of a pseudo-class be ignored by the parser ? Or do they increase the selector's specificity ? (See testcase below).

The interoperable behavior today is the latter: Opera, Firefox and Safari all increase the selector's specificity. IE ignores the repeats and gives E:first-child the same specificity as E:first-child:first-child. Given that a) no such exceptions are noted in the spec and b) the author has explicitly repeated the pseudo-class, I expect this to be a bug for IE. I was wondering if this was originally intended, and whether/when it was used in practice.


<!doctype html>
        body { color:white; font-weight:bold; }

        div:first-child:first-child:first-child {
        div:first-child:first-child {
        div:first-child {

        span { color:black; }
        span:hover:hover { background-color:yellow; }
        span:hover { background-color:red; }
                <p>If :first-child repeats increase specificity then this text has a green background</p>
        <span>If :hover:hover has higher specificity then this will get a yellow background when hovered....</span>
Received on Tuesday, 14 July 2009 18:36:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 11 February 2015 12:34:27 UTC