W3C home > Mailing lists > Public > www-style@w3.org > May 2002

Selector specificity for the more unusual selector types

From: Liorean <Liorean@user.bip.net>
Date: Sat, 25 May 2002 16:32:20 +0200
Message-Id: <5.1.0.14.0.20020525155754.00b3a598@pop3.bip.net>
To: www-style@w3.org
Hello!


I've got a small wondering about the specificity of some selectors, namely 
the attribute selectors [class~="blah"] and [id="blah"], since those are, 
at least in what element they affect equal to the .blah and #blah 
selectors. Are all attribute selectors of the same specificity, or does the 
specificity differ depending on what attribute you look at? If it's equal 
for all attribute selectors, is there any way to raise the specificity of 
[id="blah"] to that of #blah?


#blah2 #blah             { /* Specificity 2,0,0 */
                          color: blue;
                          }

#blah                    { /* Specificity 1,0,0 */
                          color: red;
                          }

[id="blah2"] [id="blah"] { /* Specificity 0,2,0 or 2,0,0? */
                          color: green;
                          }

[id="blah"]              { /* Specificity 0,1,0 or 1,0,0? */
                          color: yellow;
                          }

[id="blah2"] [id="blah"] { /* Specificity ? (Does this overrule the next 
rule?)*/
                          color: maroon !important;
                          }

[id="blah"]              { /* Specificity ? */
                          color: olive !important;
                          }


<div id="blah2">
   <div id="blah">
     content
   </div>
</div>

Will "content" take the colour maroon or olive?
// Liorean
Received on Saturday, 25 May 2002 10:40:01 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:14 GMT