Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@csstools/postcss-content-alt-text

Package Overview
Dependencies
Maintainers
0
Versions
6
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

  • 2.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
545K
increased by6.99%
Maintainers
0
Weekly downloads
 
Created
Source

PostCSS Content Alt Text PostCSS Logo

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

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

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

.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.

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

Keywords

FAQs

Package last updated on 01 Nov 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