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?
The :first-child pseudo class means "if this element is the first child of its parent". :last-child means "if this element is the last child of its parent". Note that only element nodes (HTML tags) count, these pseudo-classes ignore text nodes. This is the div id="test".
The CSS child selector has two selectors separated by a > symbol. The first selector indicates the parent element. The second selector indicates the child element CSS will style.
The :last-child CSS pseudo-class represents the last element among a group of sibling elements.
: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.
"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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With