Query browser compatibility data for web features using the caniuse CLI tool.
Before querying, verify caniuse-cli is installed:
which caniuse || echo "NOT_INSTALLED"
If not installed, tell the user:
> caniuse-cli is not installed. Install it with:
> ```bash
> npm install -g @bramus/caniuse-cli
> ```
Run the caniuse command with the feature name:
caniuse <feature-name>
Feature name formats:
caniuse viewport-unitscaniuse "viewport units"caniuse @propertyCommon feature name mappings (user term → caniuse query):
:has() selector → css-has:where() selector → css-where:is() selector → css-matches-pseudocss-container-queries (size) or css-container-queries-style (style)css-nestingsubgridcss-aspect-ratioflexbox-gapcss-gridflexboxJS/API features:
es6-moduleasync-functionsmdn-javascript_operators_optional_chainingfetchserviceworkerswebgpuAfter running the command:
If caniuse returns "Nothing was found":
:has() → css-has)css- prefix (e.g., css-grid, css-variables)mdn- prefix for JS features:has() → has or css-hascontainer-queries> This feature might not be in the caniuse database, or uses a different name.
> Check https://caniuse.com to find the correct feature name.
共 1 个版本