- 2

How to add two variables in css

21st May 2018, 9:00 AM
praveen
praveen - avatar
6 Answers
+ 14
You add them by the plus sign (+) var a; var b; var result = a + b; Or when you are taking input don't forget to use parseInt() to get the numerical value. var a = parseInt(prompt("Enter No. 1")) ; var b = parseInt(prompt("Enter No. 2")) ; var result = a + b;
21st May 2018, 9:38 AM
Nikhil
Nikhil - avatar
+ 10
storm, Brains, because css isn't a programming language doesn't mean there is no variable in css. ref: https://www.w3schools.com/css/css3_variables.asp CSS Variable Syntax: :root { --blue: #00f; --padding: 15px; } body { background: var(--blue); padding: var(--padding); } praveen you can add 2 JS variable, like this: var a = 'uuu'; var b = 'ccc'; if you want to add 2 JS variable into one, do this: var c = a+b; // c = uuuccc hope it help
21st May 2018, 9:46 AM
Amethyst Animion
Amethyst Animion - avatar
+ 3
css isnt a programming language so this isnt possible unless youre using a preprocessor
21st May 2018, 9:07 AM
᠌᠌Code X
᠌᠌Code X - avatar
+ 3
Hi praveen , CSS with advanced version such as SASS allow variables but still we cannot add two variables. Talking about JavaScript, Nikhil has something for you.
21st May 2018, 9:40 AM
Sachin Artani
Sachin Artani - avatar
+ 2
sorry i meant javascript
21st May 2018, 9:25 AM
praveen
praveen - avatar
+ 1
html and css are not programming languages. thus, they have no variables.
21st May 2018, 9:03 AM
storm
storm - avatar