
Security News
Meet Socket at Black Hat and DEF CON 2025 in Las Vegas
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
@csstools/postcss-content-alt-text
Advanced tools
Generate fallback values for content with alt text
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.
.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: ">" / "";
}
Add PostCSS Content Alt Text to your project:
npm install postcss @csstools/postcss-content-alt-text --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssContentAltText = require('@csstools/postcss-content-alt-text');
postcss([
postcssContentAltText(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
The preserve
option determines whether the original notation
is preserved. By default, it is preserved.
postcssContentAltText({ preserve: false })
.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: ">" ;
}
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.
postcssContentAltText({ stripAltText: true })
.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: ">" / "";
}
FAQs
Generate fallback values for content with alt text
The npm package @csstools/postcss-content-alt-text receives a total of 881,457 weekly downloads. As such, @csstools/postcss-content-alt-text popularity was classified as popular.
We found that @csstools/postcss-content-alt-text demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.
Security News
Deno 2.4 brings back bundling, improves dependency updates and telemetry, and makes the runtime more practical for real-world JavaScript projects.