define variables in css code example
Example 1: css set variable
:root {
--main-bg-color: coral;
}
#div1 {
background-color: var(--main-bg-color);
}
#div2 {
background-color: var(--main-bg-color);
}
Example 2: create variable in css
:root {
--tab-count: 5;
}
#div1 {
width: calc(100% - var(--tab-count));
}
Example 3: how to use variables in css
:root {
--clr-primary-1: hsl(205, 86%, 17%);
}
.container{
background-color: var(--clr-primary-3);
}