CSS: ::first-line

By Xah Lee. Date: . Last updated: .

The ::first-line CSS: What is Pseudo Element let you style the first formatted line.

The “first-line” is determined by rendering, not by physical line break.

example:

Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, «and what is the use of a book,» thought Alice «without pictures or conversation?».

Here is the code:

p.fstline274::first-line {
color:red;
}
<p class="fstline274">Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, «and what is the use of a book,» thought Alice «without pictures or conversation?».</p>

CSS: Pseudo-Elements