Given the following class declarations and code...
.foo > a { color:green; }
.bar a { color:red; }
<div class="bar">
<div class="foo">
<a href="#">SOME LINK</a>
</div>
</div>
... I thought that the link would be green because, while both declarations have a class (010) and an element (001), .foo
has the direct descendant selector. But alas, the link is red. Why?
ab
` - `p span` is same as `p > span`. So, it is conflicting to do a precedence. Also, if there are nested elements, even then a child is also a descendant. Hence CSS specs have no notion of combinator precedence and relies on order in such cases. – Abhitalks Nov 29 '14 at 15:28