English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive List of CSS Properties

CSS :first-letter pseudo-element

Complete CSS Selector Reference Manual

Online example

The style selected for the first letter of each <p> element:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title>/title> 
<style>
p:first-letter
{
    font-size:200%;
    color:#0000ff;
}
</style>
</head>
<body>
<h1>Welcome to My Homepage</h/h1>
<p>My name is Jack.</p>/p>
<p>I live in Shanghai.</p>/p>
<p>My best friend is Linda.</p>/p>
</body>
</html>
Test and see ‹/›

Definition and Usage

:first-The letter selector is used to specify the style of the first letter of an element.

Hint: :first-The letter selector can use the following properties: 

  • 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: "first-letter" Selector is only applicable to block-level elements.

Browser Compatibility

The numbers in the table indicate the first browser version number that supports the attribute.

Selector




::first-letter1.09.0
Part from5.5
1.01.07.0
Part from5.5

Note: IE 5.5-8 and Opera 4-6 Only supports the old syntax standard, single-colon CSS2Syntax (:first-letter). New versions support the standard, double colon CSS3Syntax (::letter).

Related Reading

CSS Tutorial: CSS Pseudo-elements

Complete CSS Selector Reference Manual