# @csstools/postcss-content-alt-text

> Generate fallback values for content with alt text

Latest version **3.0.4** (published 2026-09-06) · MIT-0 license · 0 weekly downloads

## Install

```sh
npm install @csstools/postcss-content-alt-text
pnpm add @csstools/postcss-content-alt-text
yarn add @csstools/postcss-content-alt-text
bun add @csstools/postcss-content-alt-text
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 3.0.4 |
| Published | 2026-09-06 |
| First published | 2024-07-07 |
| Weekly downloads | 0 |
| License | MIT-0 |
| TypeScript types | none |
| Module format | ESM |
| Node | >=20.19.0 |
| Dependencies | 4 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1052 |
| Maintainers | jonathantneal, alaguna, romainmenke |
| Keywords | accessibility, alt, content, css, csswg, fallback, postcss-plugin, w3c |

## Links

- npm: https://www.npmjs.com/package/@csstools/postcss-content-alt-text
- Repository: https://github.com/csstools/postcss-plugins
- Homepage: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-content-alt-text#readme
- Issues: https://github.com/csstools/postcss-plugins/issues
- Funding: https://github.com/sponsors/csstools
- npm.io page: https://npm.io/package/@csstools/postcss-content-alt-text

## Dependencies (4)

- [@csstools/utilities](https://npm.io/package/@csstools/utilities.md) ^3.0.0
- [@csstools/css-tokenizer](https://npm.io/package/@csstools/css-tokenizer.md) ^4.0.0
- [@csstools/css-parser-algorithms](https://npm.io/package/@csstools/css-parser-algorithms.md) ^4.0.0
- [@csstools/postcss-progressive-custom-properties](https://npm.io/package/@csstools/postcss-progressive-custom-properties.md) ^5.1.3

## Alternatives

- [style-dictionary](https://npm.io/package/style-dictionary.md) — 2.0M weekly downloads
- [postcss-merge-idents](https://npm.io/package/postcss-merge-idents.md) — 1.7M weekly downloads
- [@fontsource/noto-sans](https://npm.io/package/@fontsource/noto-sans.md) — 93.0K weekly downloads
- [uglifycss](https://npm.io/package/uglifycss.md) — 71.6K weekly downloads
- [mat4-interpolate](https://npm.io/package/mat4-interpolate.md) — 23.3K weekly downloads

## Recent versions

- 3.0.4 (latest) — 2026-09-06
- 3.0.3 — 2026-08-15
- 3.0.2 — 2026-06-28
- 3.0.1 — 2026-05-13
- 3.0.0 — 2026-01-14
- 2.0.8 — 2025-09-21
- 2.0.7 — 2025-08-22
- 2.0.6 — 2025-05-27
- 2.0.5 — 2025-04-19
- 2.0.4 — 2024-11-01
- 2.0.3 — 2024-10-23
- 2.0.2 — 2024-10-10
- 2.0.1 — 2024-08-18
- 2.0.0 — 2024-08-03
- 1.0.0 — 2024-07-07

## README

# PostCSS Content Alt Text [<img src="https://postcss.github.io/postcss/logo.svg" alt="PostCSS Logo" width="90" height="90" align="right">][PostCSS]

`npm install @csstools/postcss-content-alt-text --save-dev`

[PostCSS Content Alt Text] generates fallback values for `content` with alt text following the [CSS Generated Content Module].

```css
.foo {
	content: url(tree.jpg) / "A beautiful tree in a dark forest";
}

.bar {
	content: ">" / "";
}

/* becomes */

.foo {
	content: url(tree.jpg)  "A beautiful tree in a dark forest";
	content: url(tree.jpg) / "A beautiful tree in a dark forest";
}

.bar {
	content: ">" ;
	content: ">" / "";
}
```

## Usage

Add [PostCSS Content Alt Text] to your project:

```bash
npm install postcss @csstools/postcss-content-alt-text --save-dev
```

Use it as a [PostCSS] plugin:

```js
const postcss = require('postcss');
const postcssContentAltText = require('@csstools/postcss-content-alt-text');

postcss([
	postcssContentAltText(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
```



## Options

### preserve

The `preserve` option determines whether the original notation
is preserved. By default, it is preserved.

```js
postcssContentAltText({ preserve: false })
```

```css
.foo {
	content: url(tree.jpg) / "A beautiful tree in a dark forest";
}

.bar {
	content: ">" / "";
}

/* becomes */

.foo {
	content: url(tree.jpg)  "A beautiful tree in a dark forest";
}

.bar {
	content: ">" ;
}
```

### stripAltText

The `stripAltText` option determines whether the alt text is removed from the value.  
By default, it is not removed.  
Instead it is added to the `content` value itself to ensure content is accessible.

Only set this to `true` if you are sure the alt text is not needed.

```js
postcssContentAltText({ stripAltText: true })
```

```css
.foo {
	content: url(tree.jpg) / "A beautiful tree in a dark forest";
}

.bar {
	content: ">" / "";
}

/* becomes */

.foo {
	content: url(tree.jpg) ;
	content: url(tree.jpg) / "A beautiful tree in a dark forest";
}

.bar {
	content: ">" ;
	content: ">" / "";
}
```

[cli-url]: https://github.com/csstools/postcss-plugins/actions/workflows/test.yml?query=workflow/test
[css-url]: https://cssdb.org/#content-alt-text
[discord]: https://discord.gg/bUadyRwkJS
[npm-url]: https://www.npmjs.com/package/@csstools/postcss-content-alt-text

[PostCSS]: https://github.com/postcss/postcss
[PostCSS Content Alt Text]: https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-content-alt-text
[CSS Generated Content Module]: https://drafts.csswg.org/css-content/#content-property

---
_Source: https://npm.io/package/@csstools/postcss-content-alt-text · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
