264 of 313 menu

The first-line pseudo-element

The first-line pseudo-element allows you to style the first line of a text.

Syntax

selector::first-line { }

Example

Let's color the first line of a text in each paragraph red:

<p> some long text </p> <p> some long text </p> p::first-line { color: red; } p { width: 300px; text-align: justify; }

:

Example

Let's set the paragraph width as a percentage. Run the given code and change the width of the browser window:

<p> some long text </p> <p> some long text </p> p::first-line { color: red; } p { width: 50%; margin: 0 auto; text-align: justify; }

:

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline