---
title: "CSS content accepts alternative text · Ihab Khattab"
description: "The CSS content property accepts alternative text after a slash, so generated content in ::before and ::after no longer has to hurt screen reader users."
url: "https://ihabkhattab.com/til/css-content-alt-text/"
---

# CSS content accepts alternative text

May 19, 2026 · [Also on X](https://x.com/HO_BA/status/2056616160716612033)

The CSS `content` property accepts alternative text after a slash, so generated content in `::before` and `::after` no longer has to hurt screen reader users.

```css
.new-item::before {
  /* "black star" and element content is read out */
  content: "★";

  /* "Highlighted item" and element content is read out */
  content: "★" / "Highlighted item";

  /* Generated content is ignored and only element content is read out */
  content: "★" / "";
}
```

Supported in every major engine since Firefox 128. Via [Stefan Judis](https://www.stefanjudis.com/today-i-learned/css-content-accepts-alternative-text/).

[← All TILs](https://ihabkhattab.com/til/)
