CSS ::first-line Selector
What is CSS ::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.
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.
<!DOCTYPE html>
<html>
<head>
<title>CSS ::first-line Selector</title>
<style>
p::first-line {
color: #FF0000;
}
</style>
</head>
<body>
<p>This example is first-line <br /> of every paragraph.</p>
<p>This example is first-line <br /> of another one paragraph.</p>
</body>
</html>
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.