πŸ’‘ 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
Mentoring

Rocket Launch Your Career

Speed up your learning progress with our mentorship program. Join as a mentee to unlock the full potential of Webtips and get a personalized learning experience by experts to master the following frontend technologies:

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.