This page is Ready to Use

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.

::first-line

Summary

Represents the first line of an element. Note that the content of the first line varies depending on the available width and the styling of text (size, spacing).

Syntax

::first-line {}

Usage

The ::first-line pseudo-element can be attached to block-level elements. It can be attached to inline elements if you set the corresponding display property to block.

Examples

The following example puts the first line of any paragraph in bold text

p::first-line {
    font-weight: bold;
}

View live example

Notes

Remarks

Only the following properties apply to the ::first-letter pseudo-element: background, clear, color, font, font-family, font-size, font-style, font-variant, font-weight, line-height, text-decoration, text-transform, vertical-align, and word-spacing

Related specifications

W3C CSS 2.1 Selectors
W3C Recommendation
W3C CSS Selectors Level 3
W3C Recommendation

Attributions

  • Microsoft Developer Network.