
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
postcss-selector-not
Advanced tools
PostCSS plugin to transform :not() W3C CSS level 4 pseudo class to :not() CSS level 3 selectors
The postcss-selector-not package is a PostCSS plugin that transforms :not() pseudo-class selectors to work with older browsers that do not support them. It helps in writing more maintainable and readable CSS by allowing the use of the :not() pseudo-class in a way that is compatible with a wider range of browsers.
Transform :not() pseudo-class
This feature transforms the :not() pseudo-class to a format that is compatible with older browsers. In this example, the CSS rule 'a:not(.foo) { color: red; }' is processed to ensure compatibility.
const postcss = require('postcss');
const selectorNot = require('postcss-selector-not');
const css = 'a:not(.foo) { color: red; }';
postcss([selectorNot]).process(css).then(result => {
console.log(result.css);
});
postcss-preset-env allows you to use future CSS features today by converting modern CSS into something most browsers can understand. It includes a variety of plugins, including one that handles :not() pseudo-classes, making it a more comprehensive solution compared to postcss-selector-not.
postcss-nesting enables nesting of CSS rules, which can sometimes overlap with the use of :not() pseudo-classes for scoping styles. While it doesn't directly transform :not() selectors, it provides a different approach to writing maintainable CSS.
npm install postcss-selector-not --save-dev
PostCSS Selector Not transforms :not() W3C CSS level 4 pseudo classes to :not() CSS level 3 selectors following the Selectors 4 Specification.
p:not(:first-child, .special) {
color: red;
}
/* becomes */
p:not(:first-child):not(.special) {
color: red;
}
[!CAUTION] Only lists of simple selectors (
:not(.a, .b)
) will work as expected. Complex selectors (:not(.a > .b, .c ~ .d)
) can not be downgraded.
Add PostCSS Selector Not to your project:
npm install postcss postcss-selector-not --save-dev
Use it as a PostCSS plugin:
const postcss = require('postcss');
const postcssSelectorNot = require('postcss-selector-not');
postcss([
postcssSelectorNot(/* pluginOptions */)
]).process(YOUR_CSS /*, processOptions */);
FAQs
PostCSS plugin to transform :not() W3C CSS level 4 pseudo class to :not() CSS level 3 selectors
The npm package postcss-selector-not receives a total of 6,289,004 weekly downloads. As such, postcss-selector-not popularity was classified as popular.
We found that postcss-selector-not demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 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
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.