Use `::first-letter` to style the first letter of an element’s text without wrapping that letter in an HTML element. The double colon identifies it as a pseudo-element: it selects part of an element rather than the whole element. section 1.6.3
Accent the opening paragraph
Start with a paragraph immediately after a header. Add `header + p::first-letter { color: crimson; font-style: italic; }`. The adjacent sibling selector picks that paragraph; `::first-letter` makes only its opening letter crimson and italic. section 1.6.3
For a drop cap, `p:first-of-type::first-letter` combines a pseudo-class that picks the first paragraph with a pseudo-element that picks its opening letter. Increase its font size, adjust its line height, and float it left so the following text wraps beside it. An ornate font can make the letter stand out, but such fonts are better kept to short pieces of text. section 7.1.3
Listing 7.4 Styling and positioning the first letter of the first paragraph
@import url(
'https:/ /fonts.googleapis.com/css2?
family=Passions+Conflict&display=swap' #1
);
p:first-of-type::first-letter { #2
font-size: 6em; #2
float: left; #2
line-height: .5; #2
font-family: 'Passions Conflict', cursive; #2
} #2
See the complete drop-cap CSS, including the imported font, font size, line height, and left float. section 7.1.3
