MDN wants to talk to developers like you:


This translation is incomplete. Please help translate this article from English.


La pseudo-classe CSS :first-of-type representa el primer germà del seu tipus en la llista dels fills del seu element pare.


:first-of-type { style properties }


Aquest exemple mostra com s'assumeix el selector universal quan no s'escriu cap selector simple.

div :first-of-type {
  background-color: lime;
  <span>This span is first!</span>
  <span>This span is not. :(</span>
  <span>what about this <em>nested element</em>?</span>
  <strike>This is another type</strike>
  <span>Sadly, this one is not...</span>

...donarà com a resultat:


Especificació Estat Comentari
Selectors Level 4
The definition of ':first-of-type' in that specification.
Working Draft Sense canvis
Selectors Level 3
The definition of ':first-of-type' in that specification.
Recommendation Definició inicial

Característica Chrome Firefox (Gecko) Internet Explorer Opera Safari
Suport bàsic 1.0 3.5 (1.9.1) 9.0 9.5 3.2
Característica Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Suport bàsic 2.1 1.0 (1.9.1) 9.0 10.0 3.2


Document Tags and Contributors

 Contributors to this page: Legioinvicta
 Last updated by: Legioinvicta,