Change Variables With JavaScript

CSS variables have access to the DOM, which means that you can change them with JavaScript.

Here is an example of how you can create a script to display and change the --blue variable from the example used in the previous pages. For now, do not worry if you are not familiar with JavaScript. You can learn more about JavaScript in our :

Example

 

Browser Support

The numbers in the table specify the first browser version that fully supports the var() function.

Function          
var() 49.0 15.0 31.0 9.1 36.0

CSS var() Function

Property Description
  Inserts the value of a CSS variable

 

 
Variables and JavaScript

Login
ADS CODE