useGenericFontNames (CSS)
Language CSS
Summary
Section titled “Summary”- Rule available since:
v1.8.0 - Diagnostic Category:
lint/a11y/useGenericFontNames - This rule is recommended, meaning it is enabled by default.
- This rule doesn’t have a fix.
- The default severity of this rule is error.
- Sources:
- Same as
font-family-no-missing-generic-family-keyword - Inspired from
css/font-family-fallbacks
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "a11y": { "useGenericFontNames": "error" } } }}Description
Section titled “Description”Require a generic fallback in font-family lists.
Generic families such as serif, sans-serif, and monospace let the browser choose an
available fallback when named fonts cannot be loaded. This rule checks the font and
font-family properties.
A generic family may appear anywhere in the list. It is not required when:
- the property uses a CSS-wide keyword such as
inheritorinitial; - the
fontshorthand uses a system-font value such ascaptionormenu; - the final family comes from a custom property through
var(); font-familyappears inside an@font-facerule.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”a { font-family: Arial; }code-block.css:1:18 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Generic font family missing.
> 1 │ a { font-family: Arial; }
│ ^^^^^
2 │
ℹ Consider adding a generic font family as a fallback.
ℹ For examples and more information, see the MDN Web Docs
- serif
- sans-serif
- monospace
- etc.
a { font: normal 14px/32px -apple-system, BlinkMacSystemFont; }code-block.css:1:43 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ Generic font family missing.
> 1 │ a { font: normal 14px/32px -apple-system, BlinkMacSystemFont; }
│ ^^^^^^^^^^^^^^^^^^
2 │
ℹ Consider adding a generic font family as a fallback.
ℹ For examples and more information, see the MDN Web Docs
- serif
- sans-serif
- monospace
- etc.
a { font-family: "Lucida Grande", "Arial", sans-serif; }a { font-family: inherit; }a { font-family: sans-serif; }a { font-family: var(--font); }@font-face { font-family: Gentium; }Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.