The CSS3 :first-of-type
selector is a pseudo-class that selects an element only when this is the first element of its type. For example, if you have a paragraph with a series of span
elements inside, this selector will match only the very first element of its type. This turns out to be very useful especially when you have to deal with many elements or mixed content. Example:
p span:first-of-type {color: green}
<p>Test <span>this should be green</span> lorem ipsum dolor sit <span>amet</span> et ideo autem <span>aquis</span>.</p>