πŸ’‘ This page contain affiliate links. By making a purchase through them, we may earn a commission at no extra cost to you.
How to Create Drop Caps in CSS

How to Create Drop Caps in CSS

Ferenc Almasi β€’ Last updated 2020 August 19 β€’ Read time 1 min read
  • twitter
  • facebook
CSS

Everyone loves drop caps. In order to create one in CSS, all you have to do is use the first-letter speudo selector and you can give your letter all kinds of styles:

Copied to clipboard! Playground
/* Make drop-caps with the first-letter selector */

.dear-lorem:first-letter {
  font-size: 300%;
  float: left;
  margin: 10px;
  font-family: fantasy;
  color: #FFF;
}
drop-caps.css

There's only one problem with this. It will style the first letter of every paragraph. To get around this, change the above selector to the following:

Copied to clipboard!
.dear-lorem:first-child:first-letter { /* Your initial styles goes here */ }
drop-caps.css

This will only select the first child β€” your very first paragraph inside your content.

How to Create Drop Caps in CSS
If you would like to see more Webtips, follow @flowforfrank

Resources:

  • twitter
  • facebook
CSS
Did you find this page helpful?
πŸ“š More Webtips
Frontend Course Dashboard
Master the Art of Frontend
  • check Access 100+ interactive lessons
  • check Unlimited access to hundreds of tutorials
  • check Prepare for technical interviews
Become a Pro

Courses

Recommended

This site uses cookies We use cookies to understand visitors and create a better experience for you. By clicking on "Accept", you accept its use. To find out more, please see our privacy policy.