4

Maybe this question is ridiculous, but I want to know this fact. I have a li element with two classes (see below), but it is not working as I expected. Does anybody know the reason?

.red:first-child {
    color:#F00;
}
.blue:first-child {
    color:#00F; /* not working */
}
.red:last-child {
    color:#F00; /* not working */
}
.blue:last-child {
    color:#00F; 
}
<ul>
    <li class="red">one</li> <!-- This is the first child of red -->
    <li class="red">two</li>
    <li class="red">three</li>
    <li class="blue">one</li> <!-- and this first child of blue -->
    <li class="blue">two</li>
    <li class="blue">three</li>
</ul>
Jishnu V S
  • 8,164
  • 7
  • 27
  • 57
  • 1
    @Satpal: no its not working as expected... – Rahul Sharma Jan 02 '17 at 07:20
  • third one `
  • three
  • ` should also change the color – Rahul Sharma Jan 02 '17 at 07:20
  • that is last-child @RahulSharma – Jishnu V S Jan 02 '17 at 07:21
  • exactly..i was talking on the behalf of `
  • `
  • – Rahul Sharma Jan 02 '17 at 07:21