/* HTML */ <p class="note">Remember to save your work.</p> /* CSS */ p.note::before { content: "Note: "; color: red; font-weight: bold; }
The ::before pseudo-element adds content before the paragraph text. Here, it inserts the string 'Note: ' styled in red and bold before the original paragraph text.
The selector ul li::before targets every <li> inside a <ul> and applies the ::before pseudo-element correctly. Option B uses a single colon which is outdated for pseudo-elements.
The width: 0 and height: 0 make the pseudo-element have no visible size, so the text inside it is not shown. The content property works for text, and <p> is block by default.
Content added with ::before is not part of the HTML and may be ignored by screen readers, so important information should not rely solely on it.
h1::before { content: Hello; color: blue; }
The content property must have its text value in quotes. Without quotes, the browser treats Hello as an invalid value and ignores it, so no text appears.