npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@webref/css

v8.1.1

Published

CSS definitions of the web platform

Readme

CSS definitions of the web platform

This package contains a consolidated list of CSS features defined across specs, scraped from the latest versions of web platform specifications in webref. Fixes are applied to ensure that guarantees hold, including the ability to parse syntaxes associated with CSS features with CSSTree.

Important: If you're migrating from version 6, see the changelog for "How to upgrade" considerations.

API

Two async methods are exposed: listAll() and index(). They both resolve with an object that lists CSS features by feature type: atrules, functions, properties, selectors and types.

The difference between the two functions is that, under each feature type, listAll() returns an array of features, whereas index() returns an object indexed by feature name to ease direct lookups (and transition from mdn/data. Both functions return the same features.

Example using listAll():

const css = require('@webref/css');

const { atrules, functions, properties, selectors, types } = await css.listAll();

for (const feature of functions) {
  // do something with the object that describes the CSS function
}

Example using index():

const css = require('@webref/css');

const { atrules, functions, properties, selectors, types } = await css.index();

// Do something with the object that describes the abs() function
const abs = functions['abs()'];

Each CSS feature is described by:

  • a name key that contains the name of the feature
  • an href key that contains the URL (with a fragment) of the CSS spec that defines the feature

Many CSS features also have a syntax key that describes the syntax of the feature, as defined in the spec. This syntax can be parsed with the CSSTree Value Definition Syntax parser. Example:

const css = require('@webref/css');
const { definitionSyntax } = require('css-tree');

const { properties } = await css.index();
const ast = definitionSyntax.parse(properties['flex'].syntax);
// do something with the abstract syntax tree

Additional keys may be set depending on the type of the CSS feature. For example:

  • At-rules have a descriptors key that contains the list of descriptors defined for the given at-rule. That list may not be exhaustive. For example, it does not contain descriptors that are only implicitly defined in specs, such as families of properties that some at-rules (e.g, @position-try) accept as descriptors.
  • At-rule that are scoped to another at-rules have a for key that contains the list of scoping at-rules.
  • Functions and types that are scoped to a property or other feature have a for key that contains the list of scoping features for that feature. A scoping feature may be a property, a function or a type. When the scoping feature is a type, its name in the for key is enclosed between < and >.
  • Properties have a styleDeclaration key that contains the list of IDL attribute names that the property generates. A number of other keys may be set to describe the property's initial value, animation type and other parameters.

Additional notes:

  • Features returned by index() are indexed by their feature name, but there are exceptional cases where a given feature is defined differently (with a different syntax) for different scopes. In such cases the feature is indexed by its name completed with for and the name of the first scoping feature to which the definition applies. For example, type() for @function, type() for attr(). As of June 2025, this affects a handful of functions and types.
  • When a feature is defined across different levels in the same spec series, the definition from the latest level is used.
  • When a property is extended with new values in different specs, href links to the base definition and syntax is the union (using |) of the syntaxes of the base and extended definitions.
  • When new descriptors are defined for an at-rule in different specs, descriptors contains the merged list of known descriptors.

Migrating from mdn/data

The structure of the consolidated list of CSS features aligns with CSS data in mdn/data. If you use the index() method, the @webref/css package can almost serve as a drop-in replacement for the mdn/data package for syntaxes, with the following structural nuances:

  • mdn/data reports at-rules under an atRules key. @webref/css reports them under an atrules key.
  • mdn/data stores syntaxes of functions and types under a separate syntaxes key. @webref/css stores them in their feature definition. If you need to reproduce the syntaxes list, merge the entries under functions and types.
  • mdn/data assumes all features are unscoped. @webref/css reports scopes where needed in a for key. Note that a few functions have a different syntax depending on the scope under which they are used.
  • @webref/css does not contain information about CSS units.

Beyond structural nuances, differences in content may also affect transition:

  • mdn/data contains deprecated features, proprietary features or feature variants that are not defined in specs. @webref/css only contains features defined in specs.
  • mdn/data describes features as implemented in main browsers. @webref/css "lives on the edge", listing features and syntaxes from latest levels of CSS specs, regardless of the spec's maturity level and support across browsers.
  • mdn/data turns specs prose into syntax when needed, @webref/css only has syntaxes that are explicitly defined in specs. It should be possible to improve the specs, consider submitting missing syntax reports (against the specs themselves if possible, in Webref otherwise).

Guarantees

The following guarantees are provided by this package:

  • All syntax values (the syntax keys) can be parsed by the version of CSSTree set in peerDependencies in package.json.
  • Feature names (the name keys) are unique per type provided that the for key is also taken into account for functions and types.
  • All features have an href key that targets the CSS spec that defines the feature. When the feature is extended across CSS specs, this URL targets the base definition.

Note: there is no guarantee that functions, properties and types referenced by other constructs actually exist. The grammar is known to be incomplete.