+ 2
Why we use variables in CSS when we can use Classes for same purpose??
I'm beginner in HTML/CSS so I've this doubt, kindly reply me. Thank you :)
3 Answers
+ 5
i get you. we can easily change a style property by changing its classes, which is very true. but what if there are a property that need to be change across different class and rules that you can toggle ? for example a color and background color in dark theme ?
you would need to write another set of same classes, with slight modification in each property of it. which can be pretty tedious on the larger css file.
variable give a solution to this problem, instead of rewriting every claass you'll only need to change the variable value and everything can be change
+ 2
Actually we cant use classes for variables. they are extremely to other things.
Variables are containers that store some value
+ 2
Yeah! I got it! Thnx to both :)