Reuse one card style with different colours.
What to build
A variable that is overridden inside a section.
Requirements
:rootsets--accenttoteal..warningchanges--accenttocrimson..cardhas only aborder-leftof4px solid var(--accent)..notehas the text colourvar(--missing, navy), where--missingis never defined.
Constraints
Write exactly one .card rule, and do not write a rule like .warning .card.
Example
.dark { --bg: black; }
Why it works
Custom properties inherit, so a card reads the value from its nearest ancestor. The fallback provides a value when nothing has been defined.
Hints
Hint 1
Only the variable changes inside .warning.
Hint 2
A fallback is the second argument of var().
Solution
Show one correct solution (try it yourself first)
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Scope</title>
<style>
:root { --accent: teal; }
.warning { --accent: crimson; }
.card { border-left: 4px solid var(--accent); }
.note { color: var(--missing, navy); }
</style>
</head>
<body>
<div class="card">Normal</div>
<div class="warning"><div class="card">Danger</div></div>
<p class="note">A note</p>
</body>
</html>