universal selector specificity

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulShimm
    New Member
    • Mar 2008
    • 1

    universal selector specificity

    I have this simple div with a label in:

    Code:
    <div id="TestDiv">
        <label>TEST CSS</label> 
    </div>
    I am applying the following CSS:

    Code:
    div#TestDiv *
    
    { 
      color:Blue;
    }
    
    div#TestDiv 
    {
     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?
    Last edited by eWish; Mar 21 '08, 09:07 PM. Reason: Please use [code][/code] tags
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    Because the universal selector is all things within the div while the second is specific to the div only.

    Comment

    Working...