NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
npm
Calculate specificity of a CSS Selector
Latest stable
2.4.5
Last release 2 days ago
26 Nov 2026
Release timing varies
gaps range from 9 days to 1.9 years
Most releases are documented
notes for 10 of 16 stable releases
Nothing withdrawn
no release was ever pulled
5 years old
28 releases · first in 2022
Drag across the ruler to compare, or tap a release to open it.
🐛 fix: ignore whitespace around * in ::highlight() and ::view-transition-*()
* in ::highlight() and ::view-transition-*() (#39)🐛 fix: match pseudo-element names case-insensitively
🐛 Fix specificity for ::highlight(*) and ::highlight with no argument
::highlight(*) and ::highlight with no argumentYour coding agent can read these notes before it upgrades. Set up the MCP server →
💥 Do not crash on empty pseudo arguments
Changes & Additions Maintenance release: ⬆️ Update dev dependencies 🎨 Fix lint errors
Maintenance release:
🐛 Fix calculation of :any / :-moz-any / :-webkit-any pseudo classes
:any / :-moz-any / :-webkit-any pseudo classesnth-[last-]-child() has no childrencalculateForAST method& selectorThanks to @bartveneman for contributing some of these changes and additions.
✨ Add view-transition specificity calculation
Thanks to @bartveneman for contributing these changes and additions.
✨ Support :host() and :host-context()
::slotted():host() and :host-context()✨ Also accept single CSSTree Selector ASTs as input into calculate
Selector ASTs as input into calculateThe main change in this next iteration of @bramus/specificity is that everything is now exposed as part of a newly introduced Specificity class. The c
The main change in this next iteration of @bramus/specificity is that everything is now exposed as part of a newly introduced Specificity class. The class represents specificity value, and also holds several static methods to calculate and work with specificities.
Specificity classselector-parser from css-tree (reducing bundle size)import Specificity from '@bramus/specificity';
// ✨ Calculate specificity for each Selector in the given Selector List
const specificities = Specificity.calculate('header:where(#top) nav li:nth-child(2n), #doormat');
// 🚚 The values in the array are instances of the Specificity class
const specificity = specificities[0]; // Instance of Specificity
// 🛠 From an instance you can get the value in various formats
specificity.value; // { a: 0, b: 1, c: 3 }
specificity.a; // 0
specificity.b; // 1
specificity.c; // 3
specificity.toString(); // "(0,1,3)"
specificity.toArray(); // [0, 1, 3]
specificity.toObject(); // { a: 0, b: 1, c: 3 }
// 💡 From an instance you can also get the selector (as a String)
specificity.selectorString(); // "header:where(#top) nav li:nth-child(2n)"
// 💻 These instances also play nice with JSON.stringify()
console.log(JSON.stringify(specificity));
// {
// "selector": 'header:where(#top) nav li:nth-child(2n)',
// "asObject": { "a": 0, "b": 1, "c": 3 },
// "asArray": [0, 1, 3],
// "asString": "(0,1,3)",
// }
// 🔀 Need to compare against another instance? That's possible!
specificity.isEqualTo(specificities[1])); // false
specificity.isGreaterThan(specificities[1])); // false
specificity.isLessThan(specificities[1])); // trueREFACTOR: No longer expose calculate or any of the utility methods from the main file. Instead, provide them as static methods on Specificity which is
Changing since 2.0.0-beta.9
calculate or any of the utility methods from the main file. Instead, provide them as static methods on Specificity which is now the default export.ascending/descending to sortAsc/sortDescsortNothing published for this version
♻️ Rename Specificity.equals to Specificity.isEqualTo
Changes since 2.0.0-beta.8
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.