- DON'T use
contentto convey meaningful text (labels, state, instructions) — keep that in the DOM (WCAG F87). The alt text argument is harm reduction for cases where decoration accidentally carries meaning, not a license. - Use the alternative text argument of
contentto provide alt text for screen readers. E.g.content: url(cloud.svg) / "Save"; - Use
content: "text" / "";to prevent purely decorative text from being announced to screen readers. - DON'T use an empty alt text argument for images — they're already presentational by default. E.g. this is wrong:
content: url(cloud.svg) / "";. - DON'T use the alt text argument to describe emojis unless the description differs from the official emoji name. E.g. don't do
content: "🎉" / "celebration";, butcontent: "🎉" / "Yay!";is fine.
ONLY use the alt text argument when the text is different than the primary value and is not already present in the DOM. I.e. this is wrong:
HTML:
<button class="save">Save</button>
CSS:
button.save::before {
content: url(cloud.svg) / "Save";
}
A screen reader would read it out as "Save save".