CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS ::first-line Selector


What is ::first-line Selector?

CSS ::first-line element selector select first line of every paragraph to apply CSS style.

Only some CSS properties are used inside a ::first-line declaration block. like all font properties, margin properties, padding properties, background properties, border properties, text color and text decoration properties.

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 3.0+
  • Internet Explorer 9+
  • Opera 10+
  • Safari 1.3+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.

Syntax

General syntax of ::first-line selector,

/* CSS2 syntax */
element:first-line {
	property: value;
	property: value;
	...
}

/* CSS3 syntax */
element::first-line {
	property: value;
	property: value;
	...
}

Example:

CSS ::first-line selector select first line of every paragraph to apply CSS style.

<style type="text/css">
    p::first-line {
        font-size: 28px;
        color: #FF0000;
    }
</style>
</head>
<body>

    <p>This example is first-line of every paragraph.</p>

    <p>This example is first-line of another one paragraph.</p>

</body>

Run it...   »

Example Result: