Skip to content

Extend documentation on pseudo element content with new alt text syntax in CSS#2511

Open
maurer2 wants to merge 1 commit into
tailwindlabs:mainfrom
maurer2:main
Open

Extend documentation on pseudo element content with new alt text syntax in CSS#2511
maurer2 wants to merge 1 commit into
tailwindlabs:mainfrom
maurer2:main

Conversation

@maurer2

@maurer2 maurer2 commented Jul 21, 2026

Copy link
Copy Markdown

Hello, there's a new syntax for pseudo element content that makes it more accessible to screen readers. It seems to be working already in the latest version of tailwind, so it only needs to be added to the docs. I extended the basic example on the content-page.

I also created an example here: https://play.tailwindcss.com/OAdHWruV1H

<a href="#" class="after:content-['_↗'/'Opens_in_new_window_or_tab']">Link</a>

compiles to

{
content: ' ↗'/'Opens in new window or tab';
}

Image:
image

Cheers

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

@maurer2 is attempting to deploy a commit to the Tailwind Labs Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Jul 21, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

The change is purely additive documentation — no code paths are affected and the CSS syntax demonstrated is well-formed and already verified working in the Tailwind playground.

The alt text feature is inserted directly into the "Basic example" section rather than getting its own subsection, which slightly reduces the documentation's readability for newcomers. This is a minor structural concern with no functional impact on the library itself.

src/docs/content.mdx — worth reconsidering whether the alt text syntax belongs in the basic example or deserves its own subsection.

Reviews (1): Last reviewed commit: "Added example of alt text syntax for pse..." | Re-trigger Greptile

Comment thread src/docs/content.mdx
Comment on lines 20 to 49
@@ -29,7 +29,7 @@ Use the `content-[<value>]` syntax, along with the `before` and `after` variants
Higher resolution means more than just a better-quality image. With a Retina 6K display,{" "}
<a
href="https://www.apple.com/pro-display-xdr/"
className="font-medium text-blue-600 after:text-sm after:font-bold after:content-['_↗'] dark:text-sky-400"
className="font-medium text-blue-600 after:text-sm after:font-bold after:content-['_↗'/'Opens_in_new_window_or_tab'] dark:text-sky-400"
target="_blank"
>
Pro Display XDR
@@ -40,10 +40,10 @@ Use the `content-[<value>]` syntax, along with the `before` and `after` variants
</Example>

```html
<!-- [!code classes:after:content-['_↗']] -->
<!-- [!code classes:after:content-['_↗'/'Opens_in_new_window_or_tab']] -->
<!-- prettier-ignore -->
<p>Higher resolution means more than just a better-quality image. With a
Retina 6K display, <a class="text-blue-600 after:content-['_↗']" href="...">
Retina 6K display, <a class="text-blue-600 after:content-['_↗'/'Opens_in_new_window_or_tab']" href="...">
Pro Display XDR</a> gives you nearly 40 percent more screen real estate than
a 5K display.</p>
```

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Basic example now carries two concepts at once

The alt text feature has been folded directly into the "Basic example" section, so a reader visiting this page for the first time sees the more complex after:content-['_↗'/'Opens_in_new_window_or_tab'] class before ever seeing a plain content utility. The existing pattern in this file (and across the docs) is to give a minimal working example in the first section and introduce variations in their own ### subsections (see "Referencing an attribute value", "Using spaces and underscores", "Using a CSS variable"). A dedicated subsection — e.g. ### Providing alternate text — would keep the basic example readable and make the accessibility feature easier to discover on its own.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant