15. What are pseudo-elements in CSS and what are their uses?

Pseudo-elements allow styling specific parts of elements, such as the first letter, first line, inserting content before or after elements without adding additional HTML code. The most commonly used pseudo-elements are ::before, ::after, ::first-letter, and ::first-line.

/* Examples */ p::first-line { font-weight: bold; /* Changes the font weight of the first line of text in <p> */ } p::first-letter { font-size: 200%; /* Changes the font size of the first letter in <p> */ } .element::before { content: "Prefix"; /* Adds content before the element */ } .element::after { content: "Suffix"; /* Adds content after the element */ }
Struggling to find common date to meet with your friends? Try our new tool commondate.xyz
devFlipCards 2025

Do you accept cookies?

Cookies are small amounts of data saved locally on you device, which helps our website - it saves your settings like theme or language. It helps in adjusting ads and in traffic analysis. By using this site, you consent cookies usage.

Struggling to find common date to meet with your friends? Try our new tool
commondate.xyz