I cant understand how to use the CSS fallback thing

Tell us what’s happening:

Your code so far


<style>
:root {
  --red-color: red;
}
.red-box {
  background: fallback: red;
  background: red; 
  background: var(--red-color);
  height: 200px;
  width:200px;
}
</style>
<div class="red-box"></div>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36.

Challenge: Improve Compatibility with Browser Fallbacks

Link to the challenge:

You don’t have to use fallback keyword.

Fallback process happens automatically in the browser.

.red-box {
  background: red; 
  background: var(--red-color);
}

A browser will ignore any property that it doesn’t recognize.

In this example, Internet Explorer would ignore the line with var(--red-color) because it doesn’t support CSS variables.

Then it’s going to use whatever value it has for background, in this case red because we defined it earlier. That’s what providing a fallback is. It doesn’t require you to use fallback keyword :wink:

1 Like