Make a drop-cap effect using CSS

Learn: How to make drop-case effect using CSS? This article contains detailed tutorial to make drop-case effect using CSS.
Submitted by Abhishek Pathak, on July 17, 2017

While reading books you must have noticed the first letter is different from other paragraph in terms of size or design. This is a tradition that is being followed over the years. It makes the text look pretty and gives it a bold start.

Here's an example of Drop-Cap effect:

drop cap using CSS


Well, this form of styling is much easier than you might think. We will use CSS pseudo selectors namely :first-of-type and :first-letter.

We will target the paragraph, since they represent the text of an article or book.

p:first-of-type:first-letter {
  font-size: 32px;
  font-weight: 700;

The p is the paragraph element selector and we will apply the pseudo selectors to it. Now, if we apply only :first-letter to it, all the paragraphs would have their beginning first letter styled as drop-cap effect.

To avoid this, we will use :first-of-type which will select only the first of its type. Then we give it properties that make it larger and bolder than rest of the text.


HTML code with CSS:

<!DOCTYPE html>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Drop-cap Effect</title>
    p:first-of-type:first-letter {
      font-size: 32px;
      font-weight: 700;
  <p>This is a simple paragraph Lorem ipsum dolor sit amet, consectetur adipisicing elit. Delectus ullam fugiat accusamus tempore sapiente voluptate, asperiores tenetur ea odio architecto!</p>
  <p>What's up Lorem ipsum dolor sit amet, consectetur adipisicing elit. Alias, enim?</p>

There you go! Nice and Easy!

CSS Tutorial & Examples »



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.