CSS ::first-letter Selector


Example

Select and style the first letter of every <p> element:

p::first-letter {
  font-size: 200%;
  color: #8A2BE2;
}
Try it Yourself »

Definition and Usage

The ::first-letter selector is used to add a style to the first letter of the specified selector.

Note: The following properties can be used with ::first-letter: 

  • font properties
  • color properties
  • background properties
  • margin properties
  • padding properties
  • border properties
  • text-decoration
  • vertical-align (only if float is 'none')
  • text-transform
  • line-height
  • float
  • clear

Note: The ::first-letter selector can only be used with block-level elements.

Version: CSS1

Browser Support

The numbers in the table specifies the first browser version that fully supports the selector.

Selector
::first-letter 1.0 9.0 1.0 1.0 7.0

CSS Syntax

::first-letter {
  css declarations;
} Demo

Related Pages

CSS tutorial: CSS Pseudo elements


Copyright 1999-2023 by Refsnes Data. All Rights Reserved.