I am trying to inherit the global font-family in a variable. However this does not work.
:root {
--special-font: sans-serif;
}
html {
font-family: serif;
}
.highlight {
font-family: var(--special-font);
}
.special {
--special-font: inherit;
}
/* .special {
--special-font: serif;
} */
/* .special .highlight {
font-family: inherit;
} */
<html>
<body>
<div>
<p>
Standard Font: Serif
</p>
<p class="highlight">
Highlight Font: Sans Serif
</p>
</div>
<div class="special">
<p class="highlight">
Special Highlight: should be Serif
</p>
</div>
</body>
</html>
Both the commented out rules would work. But I would prefer to not repeat myself. Is there something I am missing?