Skip to content Skip to sidebar Skip to footer

Is It Valid To Have The Style On An Element Have An Inherit Value In The Font Family For When The Font Is Missing?

If I have a page that this HTML Hello World Is it valid to set the

Solution 1:

inherit exists on it's own. Adding inherit will inherit the parent font-family, whether it's own font-family exists or not (i.e the font-family you declared for span will be ignored even if it exists, it will just inherit the body's font-family).

You can simply do:

body {
   font-family: Helvetica;
}
span {
   font-family: Segue, Helvetica;
}

That way, it uses Segue, if it is not available it shifts to Helvetica. So in your code, in the span style, declare the fonts you want it to fall back to, separated by commas.


Solution 2:

It's invalid. inherit may only exist on its own in a property declaration.

While the entire declaration is in fact ignored, it appears to work because font-family is inherited by default anyway.

Without using custom properties, it's not possible for an element to fall back to its parent's font stack without respecifying the entire stack as fallbacks.


Post a Comment for "Is It Valid To Have The Style On An Element Have An Inherit Value In The Font Family For When The Font Is Missing?"