The CSS variables are just like simple variable of any programming language. These variables are used to store values and have a scope in which the variables can be used. A variable is defined by using two dashes(–) at the beginning and then the name which is case-sensitive. The benefit of variables is that it allows the same values to be reused at multiple places and updated/modified from one place. Also, the variable names are easier to understand and use, compared to the values of colors.
var( --custom-name, value )
Parameters: The variable var() accepts two parameters which are listed below:
- –custom-name It is a required parameter which accepts the custom property name.
- value: It is an optional parameter. It accepts fallback value which is used when custom property is invalid.
Supported Browsers: The browser supported by CSS variables are listed below:
- Google Chrome 49.0
- Internet Explorer 15.0
- Firefox 31.0
- Safari 9.1
- opera 36.0
- How to define colors as variables in CSS ?
- PHP | $_FILES Array (HTTP File Upload variables)
- Variables in TypeScript
- Python Variables
- How to pass PHP Variables by reference ?
- Perl | Variables
- Difference between static and non-static variables in Java
- How to avoid Compile Error while defining Variables
- GRE Data Analysis | Distribution of Data, Random Variables, and Probability Distributions
- SASS | Variables
- ES6 | Variables
- Ruby | Class Method and Variables
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.