Search⌘ K

Text Styling Pseudo-Elements

Explore how to use CSS text styling pseudo-elements such as ::first-letter, ::first-line, ::selection, and ::placeholder to apply unique styles to specific text parts. This lesson helps you understand and implement these selectors to enhance typography and user interaction on your web pages.

Text styling pseudo-elements allow us to apply styles to specific parts of the text within an element, such as the first letter or the first line.

::first-letter

The ::first-letter pseudo-element styles the first letter of the first line of a block-level element.

In the above CSS code, we style the first letter of the paragraph to create a drop-cap effect.

::first-line

The ::first-line pseudo-element styles the first line of a block-level element.

The above CSS style applies bold weight ...