Example
Select and style the first line of every <p> element:
p::first-line
{
background-color: yellow;
}
Try it Yourself »
Definition and Usage
The ::first-line selector is used to add a style to the first line of the specified selector.
Note: The following properties can be used with ::first-line:
- font properties
- color properties
- background properties
- word-spacing
- letter-spacing
- text-decoration
- vertical-align
- text-transform
- line-height
- clear
Note: The ::first-line 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-line | 1.0 | 9.0 Partial from 5.5 |
1.0 | 1.0 | 7.0 Partial from 3.5 |
Note: IE 5.5-8 and Opera 4-6 only support the old, single-colon CSS2 syntax (:first-line). Newer versions support the standard, double-colon CSS3 syntax (::first-line).
CSS Syntax
Related Pages
CSS tutorial: CSS Pseudo elements