::before

noun

say it: “DUB-ul KOH-lun bih-FOR” /ˈdʌbəl ˈkoʊlən bɪˈfɔːr/ or “bih-FOR” /bɪˈfɔːr/

A pseudo-element that adds a box at the start of an element's content. It shows nothing until you give it a content value, even an empty one.

What does ::before do?

::before adds generated content at the start of an element, set with the content property.

.tip::before { content: "💡 "; }

In a sentence

  • “I used ::before with content: "▶ " to put a play arrow in front of the song that's playing.”

Level: Apprentice · More CSS terms at this level

Updated