CSS ::first-letter Pseudo-Element
The ::first-letter pseudo-element is used to style the first letter of a block-level element, such as a paragraph or heading. It is often used for drop caps or decorative text styling.
1. Syntax
Example:
✅ The first letter of each <p> will be larger, red, and bold.
2. Example – Drop Cap Style
✅ The first letter is enlarged and styled like a drop cap, floating beside the text.
3. Styling Properties that Work with ::first-letter
š¹ Allowed Properties
-
color -
font-size -
font-weight -
font-family -
text-transform -
background -
float -
margin -
padding -
border -
text-shadow
❌ Not Allowed Properties
-
line-height -
text-decoration -
box-shadow
4. Example – Fancy First Letter
✅ The first letter is enlarged with a stylish shadow.
5. Combining with ::first-line
✅ First letter gets styled, and the first line appears bold.
6. Browser Support
✅ Fully supported in Chrome, Edge, Firefox, Safari, and Opera.
7. Best Practices
✔ Use ::first-letter for drop caps or decorative headings.
✔ Combine with ::first-line for better typography control.
✔ Be mindful of unsupported properties (e.g., line-height).

