CSS Master

(Primo) #1
01-selectors/pseudo-class-first-of-type-first-letter.html (excerpt)
p:first-of-type::first-letter {
font: bold italic 3em / .5 serif;
color: #3f51b5;
}

AsFigure1.43shows,nowourparagraphwillhaveaninitialcapital,evenifit’s
precededbyaheadline.

Figure 1.43. Using :first-of-type with the ::first-letter pseudo-element

Using :nth-of-type and :nth-last-of-type
The:nth-of-type()and:nth-last-of-type()arealsofunctionalpseudo-classes.
Theyacceptthesameargumentsas:nth-child()and:nth-last-child().But
like:first-of-typeand:last-of-type,theindexesresolvetoelementsofthe
sametype.Forexample,toselectthefirstpelementandeveryothersubsequentp
element,wecanusetheoddkeywordwith:nth-of-type():

60 CSS Master

Free download pdf