- 2
How to add two variables in css
6 Réponses
+ 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;
+ 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
+ 3
css isnt a programming language so this isnt possible unless youre using a preprocessor
+ 2
sorry i meant javascript
+ 1
html and css are not programming languages.
thus, they have no variables.