initial-letter

Geoff Graham on Updated on
##description##
Ad
`, } ); } })();

initial-letter is a CSS property that selects the first letter of the element where it is applied and specifies the number of lines the letter occupies.

You may have seen something like this on news sites, where the first letter of a leading paragraph is larger than the rest of the content.

The New Yorker’s site styles the initial letter

The trick with styling the first letter of content used to take a little hack where you wrap the letter in a <span> and apply a class to style it:

/* Style that first letter! */
.first-letter {
  font-size: 35px;
  line-height: 70px;
}
<p><span class="first-letter">O</span>nce upon a time in a faraway land...</p>

That works, but it’s more HTML markup than we want and breaks up our content. Plus, it’s pain to have to apply that class manually any time you want to use it.

That where initial-letter comes in:

/* Style that first letter! */
.subhead {
  initial-letter: 2;
}
<p class="subhead">Once upon a time in a faraway land...<p>

Did you see that? The initial-letter property automatically calculates both the font size and the number of lines needed to create our stylized drop cap! Want it to take up exactly 2, 3, 4 or more lines? Tell the property and it will do the heavy lifting.

Changing the property to occupy 1, 2 and 4 lines

Syntax and Values

initial-letter: normal | [<number> <integer>];

initial-letter accepts the following values:

Examples

Drop Cap, Raised Cap and Block Cap using Initial Letter

Drop Caps are probably the most familiar use case:

Raised Caps are another example:

Block Caps harken back to old fairy tales:

Browser Support

More Information