How would you provide a fallback value when using a CSS custom property?

  • --custom-property: fallback-value, var(--fallback);
  • --custom-property: fallback-value;
  • --custom-property: var(--fallback, fallback-value);
  • --custom-property: var(fallback-value, --fallback);
To provide a fallback value for a CSS custom property, you can use the var() function. The first argument of var() is the custom property, and the second argument is the fallback value. If the custom property is not defined, the browser will use the fallback value. For example, --custom-property: var(--fallback, fallback-value); sets --custom-property to the value of --fallback if it exists, or "fallback-value" if --fallback is not defined.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *