CSS ::first-letter (:first-letter) Selector
Example
p::first-letter {
font-size: 1.5rem;
font-weight: bold;
color: red;
}
Meaning
The ::first-letter selector applies styles to the first letter of the first line of a block-level element, but only when not preceded by other content such as images or inline tables.
Note ::first-letter selector is same as :first-letter changed under CSS3 to make pseudo-elements obvious.
Version: CSS1
Standard Syntax
::first-letter (:first-letter) {
css declarations;
}
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Status
Allowable properties
Only a small subset of CSS properties can be used with the ::first-letter pseudo-element:
- All font properties: font, font-style, font-feature-settings, font-kerning, font-language-override, font-stretch, font-synthesis, font-variant, font-variant-alternates, font-variant-caps, font-variant-east-asian, font-variant-ligatures, font-variant-numeric, font-variant-position, font-weight, font-size, font-size-adjust, line-height and font-family
- All background properties: background, background-color, background-image, background-clip, background-origin, background-position, background-repeat, background-size, background-attachment, and background-blend-mode
- All margin properties: margin, margin-top, margin-right, margin-bottom, margin-left
- All padding properties: padding, padding-top, padding-right, padding-bottom, padding-left
- All border properties: the shorthands border, border-style, border-color, border-width, border-radius, border-image, and the longhands properties
- The color property
- The text-decoration, text-shadow, text-transform, letter-spacing, word-spacing (when appropriate), line-height, text-decoration-color, text-decoration-line, text-decoration-style, box-shadow, float, vertical-align (only if float is none) CSS properties