I’m working on the “Improve Compatibility with Browser Fallbacks” lesson. You’re supposed to add a browser fallback to background color in case the var doesn’t work, like on Internet Explorer. However, it doesn’t actually say what the correct syntax is.
The previous lesson provides an alternative in case the variable is invalid within the code. Its syntax is:
.penguin-top {
top: 10%;
left: 25%;
/* change code below */
background: var(--pengiun-skin, black);
/* change code above */
Where the “black” is the fallback.
When I try to follow the same syntax in the subsequent one, which I’m working on right now, it doesn’t work. Typing it on a second line also doesn’t work. What am I supposed to do?
<style>
:root {
--red-color: red;
}
.red-box {
background: var(--red-color);
height: 200px;
width:200px;
}
</style>
<div class="red-box"></div>
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36.
Link to the challenge: