no-invalid-font-style
Disallow invalid font-style descriptor values in @font-face blocks.
Rule catalog ID: R033
Targeted pattern scopeโ
- The
font-styledescriptor inside every@font-faceblock.
What this rule reportsโ
@font-faceblocks where thefont-styledescriptor value is syntactically invalid or does not match a recognized keyword or angle syntax.
Why this rule existsโ
The CSS Fonts specification defines a precise set of valid font-style values in
@font-face blocks:
- Keywords:
normaloritalic - Oblique: The keyword
obliquealone,obliquefollowed by a single angle (e.g.,oblique 10deg), orobliquefollowed by a min/max angle range (e.g.,oblique -90deg 90deg) for variable fonts that support the slant axis.
Invalid values like "bold" (not a valid style keyword), "italic 10deg"
(angle not allowed with italic), or "slant 5" (non-standard keywords) cause
the browser to either ignore the block or apply unpredictable fallback behavior.
These errors usually arise from confusion between font-style property values
(used in selectors, which do accept keywords like oblique with angles) and
font-style descriptor values (used in @font-face, with stricter syntax).
โ Incorrectโ
/* "bold" is not a valid style keyword โ it is a weight keyword */
@font-face {
font-family: "Inter";
font-style: bold;
src: url("./inter.woff2") format("woff2");
}
/* Angle is not allowed with "italic" */
@font-face {
font-family: "Inter";
font-style: italic 10deg;
src: url("./inter.woff2") format("woff2");
}
/* Unrecognized keyword "slant" */
@font-face {
font-family: "Inter";
font-style: slant 5;
src: url("./inter.woff2") format("woff2");
}
โ Correctโ
/* Simple keyword: "normal" or "italic" */
@font-face {
font-family: "Inter";
font-style: normal;
src: url("./inter-normal.woff2") format("woff2");
}
/* "italic" for italic font */
@font-face {
font-family: "Inter";
font-style: italic;
src: url("./inter-italic.woff2") format("woff2");
}
/* Oblique with an angle (variable fonts) */
@font-face {
font-family: "Inter Variable";
font-style: oblique 0deg 15deg;
src: url("./inter-variable.woff2") format("woff2-variations");
}
Stylelint config exampleโ
{ "font/no-invalid-font-style": true }