Stuck with a stubborn first letter that won’t style? Wrap it in a span, toss on class="first-letter", then drop this one-liner in your CSS:
Quick Fix: Toss this in your stylesheet for 2026 browsers:
.first-letter::first-letter {
font-weight: bold;
color: #2c3e50;
}
What’s going on here?
The ::first-letter pseudo-element targets the very first character inside any block container—letters, numbers, punctuation, even emojis.
It plays nice with float, display, and line-height, so you won’t see it bleeding onto the next line. By 2026, every major engine (Chrome 128+, Firefox 126+, Safari 17.4+, Edge 128+) supports it natively—no prefixes required.
How do you actually make this work?
Start by marking the text, then drop in your CSS rule and refresh.
- Mark the text: Wrap the paragraph in a
<p>or<div>, then slide an inner<span class="first-letter">around the first character or word.
Example:
<p><span class="first-letter">C</span>ascading Style Sheets</p> - Open your CSS file: In VS Code 1.92 (2026), hit Ctrl+P, type “style.css”, then press Enter.
- Paste the rule: Drop this snippet in, save the file:
.first-letter::first-letter {
font-weight: 700;
font-family: "Segoe UI Variable", system-ui, sans-serif;
color: #d32f2f;
text-transform: uppercase;
} - Check the browser: Hit refresh (Ctrl+F5). If the first character still ignores your styles, open DevTools (F12, Elements tab) and confirm the span is actually in the DOM.
Still not working? Try these paths.
If the styling refuses to budge, switch to one of these fallback routes.
- Path 1 – Inline style: Swap the span for
<span style="font-weight:bold;color:#d32f2f;text-transform:uppercase">C</span>as a quick sanity check. - Path 2 – Direct selector: Ditch the span entirely and style the host element straight:
article p::first-letter { … }
(Only works when the paragraph starts with the exact text you want to style.) - Path 3 – Reset cascade: In DevTools, turn off every other rule on the element until you spot the accidental override.
How can you keep this from breaking later?
Keep a small
typography.css file in your 2026 project starter kit and add these guardrails.Maintain a dedicated typography.css file in your 2026 project scaffold. Add these guardrails:
| Rule | Why it matters |
|---|---|
::first-letter { float: none !important; } |
Stops floated drop caps from wrecking layouts in Safari 17.4+. |
span { display: inline-block; } |
Makes sure the span respects padding and margins on tablets and phones. |
@supports selector(::first-letter) { … } |
Applies styles only when the browser truly supports the selector, dodging legacy quirks. |
Test on real hardware with BrowserStack’s 2026 device pool; emulate iOS 17.4 and Android 14 to catch edge cases before launch.