25

Does anyone know which browsers/version support them?

Is it safe to use them, or should I resort to PHP / javascript to generate first/last classes?

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Alex
  • 66,732
  • 177
  • 439
  • 641

3 Answers3

50

:first-child and :last-child, along with complimentary compatibility chart.

:first-child is supported IE9 properly, and IE7 and IE8 sort of (see chart).

:last-child is supported by IE9+ only.

Both of them are supported well by the good browsers.

ScottS
  • 71,703
  • 13
  • 126
  • 146
Bojangles
  • 99,427
  • 50
  • 170
  • 208
  • i wonder if you do support `first-child` why you shouldn't do `last-child` ? weird! – Behnam Esmaili Sep 04 '14 at 09:07
  • I often think the same thing as well. It's probably due to the internal implementation of something in the CSS or rendering engine. At any rate, IE9+ has decent enough market share to make it the minimum supported version of IE – Bojangles Sep 04 '14 at 09:10
10

"Can I use..." should be your go to resource for these types of questions. Here's are the compatibility tables:

first-child - http://caniuse.com/#feat=css-sel2

last-child - http://caniuse.com/#feat=css-sel3

Hristo
  • 45,559
  • 65
  • 163
  • 230
  • 1
    Except that these links don't explain IE8's partial support (yet). I'm just about to add the details and send a pull-request. – Simon East Jul 03 '13 at 23:45
2

Here's a nice table illustrating different browser support.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928