![Jhey Tompkins](https://web.dev/images/authors/jheyy.jpg) Jhey Tompkins [X](https://twitter.com/jh3yy) [GitHub](https://github.com/jh3y) [LinkedIn](https://www.linkedin.com/in/jheytompkins) [Mastodon](https://front-end.social/@jhey) [Homepage](https://jhey.dev/links) The art of styling drop caps has been around for hundreds, if not thousands of years. Its use in print styles to signify the start of a new section or chapter can be seen through history. But, it's always been problematic to style in the digital age. There hasn't been a "clean" solution to styling them.

<br />

The [CSS `initial-letter` property](https://drafts.csswg.org/css-inline-3/#sizing-drop-initials) will make things much easier.

## Browser support

Where can you try `initial-letter`? It's available in Safari and from Chrome 110. In Safari, the property needs the `-webkit-` prefix. There is an [open issue](https://bugzilla.mozilla.org/show_bug.cgi?id=1223880) for it to be implemented in Firefox.

> [!NOTE]
> **Note:** There is also an open Chromium issue detailing the related properties `initial-letter-align` and `initial-letter-wrap` that are still to be implemented as per the CSSWG spec.

Test for `initial-letter` support with:

```css
@supports (initial-letter: 1 1) { /* Your supported styles */ }
```

## Current solutions

How might you style a drop cap in CSS today?

The `::first-letter` pseudo-element gets us part of the way.

```css
p::first-letter {
  color: hsl(220, 94%, 51%);
  font-weight: bold;
  font-size: 4rem;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/qByPXby?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen qByPXby by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/qByPXby">Pen qByPXby by web-dot-dev on Codepen</a></iframe>

But then you likely need to reach for properties like "float" whilst calculating a size for that first letter.

```css
p::first-letter {
  color: hsl(220, 94%, 51%);
  font-weight: bold;
  font-size: 4rem;
  float: left;
  line-height: 1;
  margin-right: 0.25rem;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/rNrGzGJ?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen rNrGzGJ by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/rNrGzGJ">Pen rNrGzGJ by web-dot-dev on Codepen</a></iframe>

The introduction of new CSS units like `lh` could ease some of this pain. But, these have limited support too (`lh` is currently only supported in Chrome).

```css
p::first-letter {
  color: hsl(220, 94%, 51%);
  font-weight: bold;
  font-size: 3lh;
  float: left;
  line-height: 1;
  margin-right: 0.1lh;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/QWBqMmp?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen QWBqMmp by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/QWBqMmp">Pen QWBqMmp by web-dot-dev on Codepen</a></iframe>

## Introducing initial-letter

The `initial-letter` property gives you finer control over this drop cap styling. It takes two space separated values:

```css
p::first-letter {
  initial-letter: 3.5 3;
}
```

- The first argument defines the size of the letter and how many lines it will occupy. The letter will scale up whilst maintaining its aspect ratio. You can't use a negative value but you can use decimal values.
- The second argument defines the letter sink. This can be thought of as the offset for where the letter will sit. The second value is optional and can't be negative. If it isn't present, it assumes the value for the letter size floored to the nearest integer. This is equivalent to using the keyword "drop". The sink also accepts another keyword value, "raise" which is equivalent to a sink of 1.

Check out this demo where you can change the values to see how it affects the drop cap styling.
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/MWBErYp?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen MWBErYp by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/MWBErYp">Pen MWBErYp by web-dot-dev on Codepen</a></iframe>

Combine it with `::first-line` and you could have something like this

```css
p::first-line {
  font-variant: small-caps;
  font-weight: bold;
  font-size: 1.25rem;
}
p::first-letter {
  font-family: "Merriweather", serif;
  initial-letter: 3.5 3;
  font-weight: bold;
  line-height: 1;
  margin-right: 1rem;
  color: #3b5bdb;
  text-shadow: 0.25rem 0.25rem #be4bdb;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/JjBrMXZ?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen JjBrMXZ by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/JjBrMXZ">Pen JjBrMXZ by web-dot-dev on Codepen</a></iframe>

Or perhaps, give it a `border`. Note how the following example uses the "drop" keyword which would be the default if omitted and equates to 3:
`css
p::first-letter {
font-family: "Merriweather", serif;
initial-letter: 3.5 drop;
font-weight: bold;
line-height: 1;
margin-right: 1rem;
color: #3b5bdb;
border: 0.25rem dashed #be4bdb;
padding: 0.5rem;
border-radius: 5px;
}`
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/mdjBpmN?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen mdjBpmN by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/mdjBpmN">Pen mdjBpmN by web-dot-dev on Codepen</a></iframe>

Maybe add a `background` or some `box-shadow`:

```css
p::first-letter {
  font-family: "Merriweather", serif;
  initial-letter: 3.5 3;
  font-weight: bold;
  line-height: 1;
  margin-right: 1rem;
  color: var(--surface-1);
  background: #be4bdb;
  padding: 0.5rem;
  border-radius: 5px;
  box-shadow: 0.5rem 0.5rem 0 #3b5bdb;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/MWBErvv?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen MWBErvv by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/MWBErvv">Pen MWBErvv by web-dot-dev on Codepen</a></iframe>

Or clip the background to the text:

```css
p::first-letter {
  background: linear-gradient(to bottom right,#1f005c,#5b0060,#870160,#ac255e,#ca485c,#e16b5c,#f39060,#ffb56b);
  font-family: "Merriweather", serif;
  initial-letter: 3.5 3;
  font-weight: bold;
  line-height: 1;
  margin-right: 1rem;
  color: transparent;
  -webkit-background-clip: text;
  padding: 0.5rem;
}
```
<iframe allow="camera; clipboard-read; clipboard-write; encrypted-media; geolocation; microphone; midi;" loading="lazy" src="https://codepen.io/web-dot-dev/embed/OJwxZOy?height=450&amp;theme-id=light&amp;default-tab=result&amp;editable=true" style="height: 100%; width: 100%; border: 0;" title="Pen OJwxZOy by web-dot-dev on Codepen">See the Pen <a href="https://codepen.io/web-dot-dev/embed/OJwxZOy">Pen OJwxZOy by web-dot-dev on Codepen</a></iframe>

You've got a lot of possibilities!

And there you have it, finer control over your drop cap styling with `initial-letter`! Would you add drop caps to your typography? How might you style them? Let us know!