HTML/CSSIntermediate#css#pseudo-elements

What is the CSS 'content' property used for with pseudo-elements?

content is required for ::before/::after to render anything; it can insert text, counters, quotes, or images. It's commonly used for decorative icons, tooltips, and numbered list counters without extra markup.

Example
.required::after { content: ' *'; color: red; }
ol { counter-reset: section; }
li::before { counter-increment: section; content: counter(section) '. '; }

Related Questions

1
HTML/CSSBeginner#css#display

What is the difference between inline, inline-block, and block for form control styling?

Open
2
HTML/CSSAdvanced#css#internationalization

How do CSS logical properties (like margin-inline, padding-block) differ from physical properties?

Open
3
HTML/CSSIntermediate#css#functions

How does the CSS calc() function work?

Open