I've faced a little confusion about the css style replacement priority.
I have this sample code: DEMO HERE
<style>
#list div {
background-color: #999;
}
#d2 {
background-color: #fff;
color:red;
}
</style>
<div id="list">
<div>item 1</div>
<div id="d2">item 2</div>
<div>item 3</div>
<div>item 4</div>
<div>item 5</div>
</div>
My question is, Why the second background-color:#fff; in #d2 class doesn't effect on the child div? or better to ask: Why the first rule wins?
I expect that the second rule changes background color of the div
Does anyone can explain this situation?