tdarb.org > First Letter Pseudo Element

// 257 words // 1 minute read

First Letter Pseudo Element

In today’s TypeTip™ we will be taking a look at the often overlooked :first-letter CSS pseudo element. Though you might only use this for specific article-format web pages, it’s still a nice-to-have in your web dev toolset.

The HTML

Like most pseudo elements, nothing has to change with your pre-existing HTML structure:

<article>
    <p>It was a bright cold day in April, and the clocks were striking thirteen.</p>
</article>

The CSS

Here’s where the magic happens:

p:first-letter {
    color: orangered;
    font-size: 250%;
}

Live CodePen

See the Pen First Letter Pseudo Element by Bradley Taunt (@bradleytaunt) on CodePen.


Leave a comment

To make a comment, please send an e-mail using the button below. Your e-mail address won't be shared and will be deleted from my records after the comment is published. If you don't want your real name to be credited alongside your comment, please specify the name you would like to use. If you would like your name to link to a specific URL, please share that as well. Thank you.

Comment via email