freecoding.school100% FREE · NO SIGNUP
Neon DistrictISSUE #24 of 50

pseudo-elements · ::before · ::after

PrismaVSJank the Janitor
Prisma says::before and ::after inject generated content into an element — icons, labels, decorations.

These pseudo-elements create a child at the start (::before) or end (::after) of an element. They require a content property (even content:"") to appear. Use them for decorative icons, quotation marks, badges, clearfixes, and counters — without polluting the HTML.

Power-ups you unlock

Jank the Janitor attacks — common mistakes

Boss battleAdd a → arrow after every external link with a::after { content:" ↗" }.

Example code

<!doctype html><html><head><meta charset="utf-8">
<style>a::after{content:" ↗";color:#8aff9d}.req::before{content:"* ";color:#ff7a8a}</style></head><body style="background:#06040d;color:#e6e0ff;padding:20px"><p class="req">required field</p><a href="#">external link</a></body></html>
▶ Open the interactive comic issue
‹ Pseudo-Classes · :Has() · The Parent SelectorPseudo-Elements · ::First-Letter · ::First-Line ›