CSS ::first-letter Selector
What is CSS ::first-letter Selector?
CSS ::first-letter element selector select first character of every paragraph to apply CSS style.
Only some CSS properties are used inside a ::first-letter 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-letter selector,
/* CSS2 syntax */
element:first-letter {
property: value;
property: value;
...
}
/* CSS3 syntax */
element::first-letter {
property: value;
property: value;
...
}
Example
CSS ::first-letter selector select first character of every paragraph to apply CSS style.
<!DOCTYPE html>
<html>
<head>
<title>CSS ::first-letter Selector</title>
<style>
p::first-letter {
font-size: 28px;
color: #FF0000;
}
</style>
</head>
<body>
<p>This example is first-letter of every paragraph.</p>
<p>This example is first-letter 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.