By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,148 Members | 748 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,148 IT Pros & Developers. It's quick & easy.

universal selector specificity

P: 1
I have this simple div with a label in:

Expand|Select|Wrap|Line Numbers
  1. <div id="TestDiv">
  2.     <label>TEST CSS</label> 
  3. </div> 
I am applying the following CSS:

Expand|Select|Wrap|Line Numbers
  1. div#TestDiv *
  2.  
  3.   color:Blue;
  4. }
  5.  
  6. div#TestDiv 
  7. {
  8.  color:Red;
Now as I understand it the universal selector has a specificity of 0,0,0,0, so this means that both of these items have the same specificity. Therefore I would expect the label to be red as that comes afterwards in the stylesheet. So why is the label shown as blue for me?
Mar 21 '08 #1
Share this Question
Share on Google+
1 Reply


drhowarddrfine
Expert 5K+
P: 7,435
Because the universal selector is all things within the div while the second is specific to the div only.
Mar 21 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.