Mastering the Drop Cap: Why initial-letter is a Game Changer
Hey there! Grab a coffee, because we need to talk about one of those "small" CSS features that actually solves a massive headache. You know that classic magazine look where the first letter of an article is huge and spans multiple lines? It’s called a drop cap, or "Буквица" as we say in the design world. For years, achieving this look in a web browser was like trying to perform surgery with a butter knife. But thanks to the initial-letter property, we finally have a surgical tool that actually works.
How we suffered before
Back in the day, if a designer handed you a mockup with a drop cap, you’d probably sigh. We had to use the ::first-letter pseudo-element combined with float: left. Sounds simple, right? Wrong. You’d end up in a world of pain trying to calculate the exact font-size and line-height to make the top of the letter align perfectly with the top of the first line of text.
If you changed the font or used responsive (fluid) typography with the clamp() function, your carefully aligned drop cap would suddenly look like a floating mess, either crashing into the text below or leaving a weird gap at the top. We often had to resort to negative margins or even wrapping the first letter in a span and using absolute positioning—absolute madness for such a simple visual effect.
The modern way: initial-letter
Now, we have a specialized property that handles the heavy lifting. The initial-letter property tells the browser: "Hey, make this letter this many lines tall and sink it this many lines deep." The browser then handles all the complex geometry, cap-height alignment, and spacing automatically.
The beauty of this approach is that it is truly "set and forget." Because the browser understands the relationship between the glyph and the surrounding text, it stays perfectly aligned even if you change the font size or family. If you are already comfortable with properly working with cascade specificity, you'll find that applying this to your primary article paragraphs is incredibly clean and doesn't require extra wrapper tags or hacky resets.
Ready-to-use code snippet
To use this, you target the ::first-letter pseudo-element. The property takes two values: the first is the size (in lines), and the optional second value is the "sink" (how many lines it should drop). If you provide one value, the sink defaults to the same as the size.
/* Modern Drop Cap Implementation */
.article-content p:first-of-type::first-letter {
/* For Safari support, we still need the prefix */
-webkit-initial-letter: 3 2;
initial-letter: 3 2;
/* Styling to make it pop */
font-weight: 700;
color: #2a2a2a;
margin-right: 0.75rem;
padding: 0.2rem;
}
Common beginner mistake
The most common mistake I see devs make is forgetting that initial-letter only works on ::first-letter (or ::first-line in some experimental cases), and it requires the element to be a block-level container. If you try to apply it directly to an inline span, nothing will happen.
Also, watch out for the "sink" value. If you set initial-letter: 3 1, your letter will be 3 lines big but only drop down 1 line, meaning 2 lines of the letter will stick out above the first line of your paragraph. This can be a cool stylistic choice, but usually, beginners do it by accident and wonder why their layout looks broken. Stick to initial-letter: 3 (which is shorthand for 3 3) if you want a standard magazine-style drop cap that fits snugly within the text block.
🔥 We publish more advanced CSS tricks, ready-to-use snippets, and tutorials in our Telegram channel. Subscribe so you don't miss out!
Top comments (0)