The ::first-letter pseudo-element styles the first character of the first line inside a block container. It is a classic tool for drop caps and editorial typography.
01
First char
One letter only.
02
Drop cap
Magazine style.
03
:: syntax
Pseudo-element.
04
Block boxes
p, article…
05
float
Wrap text.
06
Font props
Size, color.
Fundamentals
Introduction
The ::first-letter selector in CSS is a pseudo-element used to apply styles to the first letter of the first line of text inside a block container.
It is commonly used to create drop caps in articles, blog posts, and book-style layouts where the opening letter appears larger and more decorative than the rest of the paragraph.
Definition and Usage
Append ::first-letter to a selector with no space before the colons: p::first-letter or article p::first-letter. Only the first character of the element’s first formatted line is styled.
💡
Beginner Tip
::first-letter targets exactly one character. If the text starts with a quotation mark, number, or emoji, that character receives the styling — not the first alphabetic letter after it.
Foundation
📝 Syntax
The syntax for the ::first-letter pseudo-element is:
syntax.css
element::first-letter{/* CSS properties */}
Here, element is a block container such as p, article, or h2. The pseudo-element selects only the first letter inside that element’s first line.
Not supported on plain span without display change
Browser support
All modern browsers
Context
When to Use ::first-letter
::first-letter adds editorial polish to long-form content:
Article openings — Create a magazine-style drop cap on the lead paragraph.
Chapter starts — Emphasize the beginning of a story or section.
Blog posts — Give the first paragraph a distinctive branded letter.
Pull quotes — Accent the opening character of a highlighted quote block.
Headings — Subtly enlarge the first letter of a title for decorative effect.
Preview
👀 Live Preview
The opening “W” is styled with a larger blue drop cap via p::first-letter:
Welcome to the world of CSS! This paragraph demonstrates how you can use the ::first-letter pseudo-element to create a styled drop cap effect that wraps naturally with the rest of the text.
Hands-On
Examples Gallery
Practice ::first-letter with basic drop caps, serif editorial styling, colored backgrounds, and heading accents.
📜 Drop Cap Patterns
Style the opening letter of paragraphs and articles.
Example 1 — Basic paragraph drop cap
Enlarge and float the first letter to create a classic drop cap on a paragraph.
first-letter-basic.html
<style>p::first-letter{font-size:2.5rem;font-weight:700;color:#2563eb;float:left;margin-right:0.35rem;line-height:1;}</style><p>
Welcome to the world of CSS! This paragraph demonstrates how you can use the
::first-letter selector to create a styled drop cap effect.
</p>
Once upon a time, in a quiet village surrounded by hills, a story began that would change everything. The opening letter uses a serif drop cap for an editorial feel.
How It Works
Scoping to article p limits the effect to article body copy, leaving navigation and sidebar text unchanged.
🎨 Decorative Effects
Add background color and accent styling to the opening character.
Example 3 — Colored background on the first letter
Give the first letter a pill-shaped background for a modern badge-like accent.
Headings are block containers, so h2::first-letter works without float. Use sparingly to avoid distracting from the heading’s meaning.
Watch Out
⚠️ Common Pitfalls
Inline elements — span::first-letter does not work on plain inline elements. Use a block container or set display: inline-block.
Leading punctuation — A quote mark or number at the start gets styled, not the first letter after it.
One character only — You cannot style the first two letters with ::first-letter; only the first character matches.
Float on small screens — Large floated drop caps can crowd narrow viewports; test responsive layouts.
Single vs double colon — Prefer ::first-letter (pseudo-element) over legacy :first-letter in new code.
A11y
♿ Accessibility
Decorative only — Drop caps are visual enhancements; the full word remains in the DOM for screen readers.
Do not convey meaning — Never use letter styling alone to communicate important information.
Contrast — Ensure colored or background-styled first letters meet WCAG contrast ratios.
Readability — Very large drop caps should not reduce readability of the opening lines on mobile.
🧠 How ::first-letter Works
1
Browser finds block containers
Elements like p and article that support ::first-letter are selected.
Match
2
First character is isolated
The browser creates a pseudo-element for the first letter of the first formatted line.
Pseudo
3
Styles apply to that letter
Font, color, float, and spacing properties render on the single character.
Render
=
🔠
Drop cap typography
The opening letter stands out with editorial flair.
Compatibility
🖥 Browser Compatibility
The ::first-letter pseudo-element is supported in all modern browsers and has been widely available for years.
✓ Baseline · Universal support
Drop caps everywhere
::first-letter works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Universal support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll modern versions
Full support
::first-letter pseudo-element99% supported
Bottom line:::first-letter is safe for drop caps and typographic accents in modern projects.
Wrap Up
🎉 Conclusion
The ::first-letter pseudo-element is a powerful typographic tool for styling the opening character of block-level text. From simple drop caps to colored badge accents, it adds editorial character without extra HTML.
Remember that only the first character is styled, block containers are required, and leading punctuation counts as the first letter. Pair with float and careful sizing for polished long-form layouts.
The ::first-letter pseudo-element matches the first letter of the first line inside a block container. It lets you style that single character independently — commonly for drop caps in articles.
Block containers such as p, div, article, and h1–h6, plus list items, table cells, and elements with display:inline-block. Plain inline elements like span do not support it unless you change their display.
::first-letter styles only the first character. ::first-line styles the entire first line of text inside the element.
Use the double-colon ::first-letter syntax. It is the modern standard for pseudo-elements. Single-colon :first-letter still works in browsers for backward compatibility.
Yes. All modern browsers support ::first-letter for drop caps and typographic accents. Test decorative float layouts on small screens.