Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

CSS.supports() — detecting CSS feature support

CSS.supports() checks whether the browser reports support for a specific property–value pair or CSS feature-query condition. It returns a boolean and helps select fallbacks without identifying the browser by name.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

CSS.supports(propertyName, value)
CSS.supports(supportCondition)

CSS.supports() is an operation on the CSS Web IDL namespace. You call it directly on CSS without creating an instance. It is a browser Web API, not a function defined by ECMAScript; using Node 24 alone does not establish its availability. You can check that CSS and the method exist before calling it, as the example does.

The CSS.supports(propertyName, value) form accepts two strings: a CSS property name, such as "background-color" rather than "backgroundColor", and the value being tested. It returns true or false. Test the specific value because support for a property does not imply support for all its values.

The CSS.supports(supportCondition) form accepts a condition like an @supports condition, without @supports itself or a rule block. An example is "(color: red)"; conditions can be combined with and, or, and not. CSS.supports() only returns a result—it does not apply styles. When conditional styling does not require JavaScript, you can use @supports directly in CSS.

A positive result means reported support for the tested syntax, not a guarantee of correct appearance or freedom from bugs or partial implementations. Keep baseline styles and add enhancements conditionally. Availability of the method itself does not guarantee support for every feature being tested.

Examples

if (typeof CSS === "undefined" || typeof CSS.supports !== "function") {
  console.log("CSS.supports unavailable");
} else {
  console.log(CSS.supports("color", "red"));
  console.log(CSS.supports("(color: red)"));
  console.log(CSS.supports("color", "not-a-color"));
}

Result

true
true
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources