Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Pseudo-elements

The ::first-letter pseudo-element

Reference for the CSS ::first-letter pseudo-element: style the first letter of a block for drop caps, with the list of allowed properties and common pitfalls.

The ::first-letter pseudo-element selects the first letter of the first line of a block container. It is the classic way to make drop caps and initials without wrapping the letter in a <span>.

Leading punctuation such as an opening quote is included together with the letter. The match is only made when the text really starts the block: if an image or another box comes first on the line, nothing is selected.

CSS
p::first-letter {
  font-size: 2.5em;
  font-weight: bold;
}

Try it

A floated drop cap

Syntax

CSS
selector::first-letter {
  /* a limited set of properties */
}
Property Value
Applies to Block containers (display: block, inline-block, list-item, table-cell, table-caption)
Inherited Inherits from the originating block
Animatable Its properties follow their own animation rules

Values

The pseudo-element takes no arguments. Only these groups of properties apply:

Group Examples
Fonts font-*, line-height
Color and background color, background-*, opacity
Text text-decoration, text-transform, text-shadow, letter-spacing, word-spacing, vertical-align
Box margin-*, padding-*, border-*, float, initial-letter

Usage notes

  • Only block containers. On an inline element such as <span> it does nothing unless you change display.
  • Drop cap with float. Float the letter and shrink its line-height so it spans two or three lines. Tune the size by eye, because font metrics differ.
  • The modern way. initial-letter creates drop caps with one declaration but is not supported everywhere yet.
  • Generated content counts. A ::before with text makes that text the first letter.
  • Skips non-letters carefully. Digits count as letters; punctuation directly before the letter is included, but whitespace is not.
  • Accessibility. Large initials are decorative. Keep contrast high and do not rely on them to convey meaning.
  • Script-aware. For some scripts, such as those with ligatures, the first letter may be a longer unit.

Browser support

Supported in every browser. initial-letter support is separate and more limited.