Nos bénévoles n'ont pas encore traduit cet article en Français. Inscrivez-vous et aidez-nous à réaliser cette tâche !
Vous pouvez également lire cet article en English (US).

The CSS.supports() static methods returns a Boolean value indicating if the browser supports a given CSS feature, or not.

Syntax

boolValue = CSS.supports(propertyName, value);
boolValue = CSS.supports(supportCondition);

Parameters

There are two distinct sets of parameters. The first one allows to test the support of a pair property-value:

propertyName
A DOMString containing the name of the CSS property to check.
value
A DOMString containing the value of the CSS property to check.

The second syntax takes one parameter matching the condition of @supports:

supportCondition
A DOMString containing the condition to check.

Examples

result = CSS.supports("text-decoration-style", "blink");
result = CSS.supports("display: flex");
result = CSS.supports("(--foo: red)");

result = CSS.supports(`(transform-style: preserve) or (-moz-transform-style: preserve) or
                       (-o-transform-style: preserve) or (-webkit-transform-style: preserve)`);

// result is true or false

Specification

Specification Status Comment
CSS Conditional Rules Module Level 3
The definition of 'CSS.supports()' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support28 Yes

22

201

No12.1 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support Yes Yes Yes

22

201

12.1 No ?

1. From version 20: this feature is behind the layout.css.supports-rule.enabled preference. To change preferences in Firefox, visit about:config.

See also

Étiquettes et contributeurs liés au document

Étiquettes : 
Dernière mise à jour par : valtlai,