Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. [CSS Selector] E:first-line

[CSS Selector] E:first-line

Using selector:first-line, you can apply styles to the first rendered line of an element. This is commonly called a "pseudo-element." It does not work in IE8 or earlier.

Note that this applies to the first line as rendered by the browser, not the first line in the source code. Additionally, :first-line only works when the display property is set to block, inline-block, table-cell, table-caption, etc. It does not apply to inline elements.

Sample Code

p:first-line { color: red;} /* Makes the first rendered line red. */

Browser Preview

p:first-line { color: red;} /* Makes the first rendered line red. */

<p>
	The first rendered line becomes red.
	Note that this is not the first line of the source code.<br>
</p>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
Supported in all versions
IE IE
11
10
9
8
7
6
Opera Opera
7+
6
5
4
↑ Supported as ':first-line'
2 or earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 or earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop version
Firefox Android Firefox Android
Latest
Same support as desktop version

※ Version data based on MDN.

If you find any errors or copyright issues, please .