Socket
Socket
Sign inDemoInstall

@csstools/selector-specificity

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@csstools/selector-specificity

Determine selector specificity with postcss-selector-parser


Version published
Weekly downloads
7.2M
increased by0.22%
Maintainers
2
Weekly downloads
 
Created

What is @csstools/selector-specificity?

@csstools/selector-specificity is an npm package designed to calculate the specificity of CSS selectors. This can be useful for developers who need to understand or manipulate the specificity of their CSS rules, ensuring that styles are applied as intended.

What are @csstools/selector-specificity's main functionalities?

Calculate Specificity

This feature allows you to calculate the specificity of a given CSS selector. The output is an object with properties 'a', 'b', and 'c' representing the specificity components.

const { calculate } = require('@csstools/selector-specificity');

const specificity = calculate('div.class#id');
console.log(specificity); // Output: { a: 1, b: 1, c: 1 }

Compare Specificity

This feature allows you to compare the specificity of two CSS selectors. The output is a number indicating which selector has higher specificity.

const { compare } = require('@csstools/selector-specificity');

const result = compare('div.class#id', 'div#id');
console.log(result); // Output: 1

Other packages similar to @csstools/selector-specificity

Keywords

FAQs

Package last updated on 19 Jan 2023

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