How to know if a CSS property is supported by your browser through Javascript?

1 min read  •  25 Dec 2021
Views:

There could be cases where you need to add styles to markup through javascript, but before doing that you need to be sure if that is supported by the browser on which it's running. So that you can choose what to do accordingly.

Here's how you can do that:


check-if-css-supports


In your javascript file, you can add a check like following -

if (CSS.supports(property, value)) {
  // css property is supported
} else {
  // css property is not supported
}