CKTIS / CSS
::first-letter — the first letter of text
The ::first-letter pseudo-element styles the first letter on the first formatted line, for example by changing its color or font size. The :first-letter spelling is a backward-compatible form of the same pseudo-element.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
selector::first-letter { property: value; }
/* Legacy equivalent: */
selector:first-letter { property: value; }::first-letter represents the first typographic character unit of text on the first formatted line, together with associated punctuation. It need not be a single Unicode code point or an alphabetic letter: it can be a digit, for example. It does not create a real DOM element.
The pseudo-element works on block containers, such as a paragraph with its default display, not on an ordinary display: inline element. If the first line is empty or an in-flow image precedes the text, the effect may not occur. Generated ::before text can supply the first letter instead of the source text.
Use ::first-letter in new code. The older spelling :first-letter denotes the same pseudo-element, not a pseudo-class. The applicable property set is restricted; it includes font properties, color, backgrounds, margins, borders, and padding.
The example highlights only H in Hello CSS.. It does not assume identical glyph rendering across systems. The evolving draft's precise punctuation and typographic-unit rules need separate verification in the target browser.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>First letter</title>
<style>
.sample {
color: #000000;
font: 20px/1.5 monospace;
}
.sample::first-letter {
color: #800000;
font-size: 40px;
}
</style>
<p class="sample">Hello CSS.</p>
</html>Result
Hello CSS. H: color #800000, font-size 40px. Remaining text: color #000000, font-size 20px.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.