p:first-of-type {
background: #cddc39;
}
Thiswillmatcheverypelementthat’sthefirstpelementofitsparent,shownin
Figure1.40.
Figure 1.40. Matching the first child p element
The:last-of-typepseudo-classworkssimilarly,matchingthelastsuchelement
ofitsparentaspresentedinFigure1.41.However,:only-of-typewillmatchan
elementifit’stheonlychildelementofthattypeofitsparent,illustratedinFig-
ure1.42.
58 CSS Master