Answers for "how to create a variable in css and access it in html"

CSS
57

css set variable

:root {
  --main-bg-color: coral;
}

#div1 {
  background-color: var(--main-bg-color);
}

#div2 {
  background-color: var(--main-bg-color);
}
Posted by: Guest on December-27-2019
0

css variable

...
<style>
	:root{
  		--couleur-principale: brown;
	}
	#test1{
		color:var(--couleur-principale);
	}
</style>
...
Posted by: Guest on December-09-2020

Code answers related to "how to create a variable in css and access it in html"

Browse Popular Code Answers by Language