CSS Drop Caps with the initial-letter Property
Drop caps without float hacks
The old way used float, a large font-size, and manual line-height and margin, and it broke across browsers. initial-letter gives you a real drop cap in one property.
The old hack vs the modern fix
View demo.drop-cap::first-letter {
float: left;
font-size: 3em;
line-height: 1;
margin-right: 8px;
}.drop-cap::first-letter {
-webkit-initial-letter: 3;
initial-letter: 3;
}
/* Standard; -webkit- prefix needed for Safari. */Initial letter browser support
Live demo
Why the modern way wins
One property
No float, no guessing font-size or line-height. You say how many lines the letter sinks and the browser does the rest.
Stable layout
Initial-letter is designed for drop caps. Wrapping and alignment stay consistent across browsers.
Optional raise
initial-letter: 3 2 makes a 3-line-tall letter that sinks 2 lines, so it rises 1 line above the text. You get control without fragile hacks.
- Lines Saved
- 8 → 4
- 50% less code
- Old Approach
- Float + font-size
- Line-height and margin tweaks
- Modern Approach
- initial-letter
- One property, proper drop cap
How it works
The old way: style ::first-letter with float: left, a big font-size (e.g. 3em), line-height: 1, and margin-right to clear the text. It kind of worked but line wrapping and alignment varied by browser and font, and you had to tweak by eye.
The modern way: set initial-letter: 3 (or another number). The number is how many lines tall the letter is, and by default it sinks the same number. The browser sizes and positions it correctly. Use two values for size and sink. 3 2 makes a 3-line-tall letter that sinks 2 lines, so it rises 1 line above the text. Safari requires the -webkit- prefix. One property, predictable result.