CSS generated images can have replacement text.
Most people use content to insert icons or decorative images. But what if that generated image carries information?
The content property accepts alternative text after a slash:
.element::before {
content: url('/images/status.jpg') / 'Current status: available';
}
The value after the slash is the replacement text associated with the generated content.
This syntax is widely available in browsers, but assistive-technology behavior can still vary. For meaningful content, real HTML such as <img alt="…"> remains the safer choice.
Use CSS generated content for decoration or progressive enhancement, not for information that must always be announced.
Want to build modern interfaces with less JavaScript?
I wrote a guide about building modern UI with HTML and CSS first. It covers practical patterns you can use before reaching for JavaScript.
Learn more