CSS ::first-line (:first-line) Selector

❮ Previous Selectors Next ❯

Example

p::first-line {
    font-size: 1.2rem;
    font-weight: bold;
    text-decoration: underline;
}

Meaning

The ::first-line selector applies styles to the first line of a block-level element.

The following properties apply to the ::first-line pseudo-element:

Notes:

The ::first-line pseudo-element can only be applied to block-level elements.

The ::first-line selector is same as :first-line changed under CSS3 to make pseudo-elements obvious.

The effects of ::first-line are limited by the length and content of the first line of text in the element.

The length of the first line depends on many factors, including the width of the element, the width of the document, and the font size of the text. ::first-line has no effect when the first child of the element, which would be the first part of the first line, is an inline block-level element, such as an inline table.

Version: CSS1




Standard Syntax

::first-line (:first-line) {
  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-line pseudo-element:

❮ Previous Selectors Next ❯