In my following code, I have defined more specific rule for h1 as #inner h1 and less specific rule as #container h1 is also defined. But if #container h1 is put after #inner h1 then it takes effect and #inner h1 is ignored while it shouldn't be because its more specific.
Please help me in understanding the issue.
CSS:
#inner h1 { font-size:25px; }
#container h1 { font-size:15px; }
HTML:
<div id="container">
<div id="inner">
<h1>Hello World!</h1>
</div>
</div>
#inner h1
is not more specific than#container h1
. They both have a specificity of 101 (I believe, htmldog.com/guides/cssadvanced/specificity). Just because an element is INSIDE another element doesn't make the one inside be more specific. – Huysmans