Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • "the blue one is similar" And that's why the asker expects .blue:first-child to match the first .blue element. But it doesn't.
    – BoltClock
    Commented Jan 2, 2017 at 8:45
  • Sorry, I didn't read it, "mea culpa". In that case, both selectors has the same "precision level", I mean, they aren't more precise than each other, so "the last one" rule applies and the one colored is the last blue.
    – amedina
    Commented Jan 2, 2017 at 8:50
  • This has nothing to do with specificity. Specificity does not preclude both .blue:first-child and .blue:last-child matching different elements (or the same element) at the same time.
    – BoltClock
    Commented Jan 2, 2017 at 8:53
  • @BoltClock You are right. Here's a codepen with the order changed.
    – amedina
    Commented Jan 2, 2017 at 9:09