Skip to content

useGenericFontNames (CSS)

Language CSS
biome.json
{
"linter": {
"rules": {
"a11y": {
"useGenericFontNames": "error"
}
}
}
}

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 inherit or initial;
  • the font shorthand uses a system-font value such as caption or menu;
  • the final family comes from a custom property through var();
  • font-family appears inside an @font-face rule.
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; }