Please assist with following, need to create a fallback before existing background declaration?
Can you share your formatted code and a link to the exercise?
Just declare the background property twice, one time with the color set normally, and one time after that using the variable.
I changed the selector, variable name and color, but it is pretty much the same as the assignment.
<style>
:root {
--main-color: #eee;
}
.container {
background: #eee;
background: var(--main-color);
}
</style>
- The browser sets the background:
background: #eee;
- If the browser doesn’t understand variables, it simply ignores the next line keeping the background color that was already set:
background: var(--main-color);