Socket
Socket
Sign inDemoInstall

@csstools/postcss-content-alt-text

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/postcss-content-alt-text

Generate fallback values for content with alt text


Version published
Maintainers
0
Created
Source

PostCSS Content Alt Text PostCSS Logo

npm version Build Status Discord

Baseline Status CSS Standard Status

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";
}

/* becomes */

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

Usage

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 */);

PostCSS Content Alt Text runs in all Node environments, with special instructions for:

Options

preserve

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";
}

/* becomes */

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

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.

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

/* becomes */

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

Keywords

FAQs

Package last updated on 07 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc