Skip to main content

font-family-no-missing-generic-family-keyword

禁止字体系列中缺少通用系列关键字。

¥Disallow a missing generic family keyword within font families.

a { font-family: Arial, sans-serif; }
/** ↑

* An example of generic family name */

通用字体系列可以是:

¥The generic font family can be:

  • 放置在字体系列列表中的任意位置

    ¥placed anywhere in the font family list

  • 如果使用与属性继承或系统字体相关的关键字,则省略

    ¥omitted if a keyword related to property inheritance or a system font is used

此规则检查 fontfont-family 属性。

¥This rule checks the font and font-family properties.

选项

¥Options

true

{
"font-family-no-missing-generic-family-keyword": true
}

以下模式被视为问题:

¥The following patterns are considered problems:

a { font-family: Helvetica, Arial, Verdana, Tahoma; }
a { font: 1em/1.3 Times; }

以下模式不被视为问题:

¥The following patterns are not considered problems:

a { font-family: Helvetica, Arial, Verdana, Tahoma, sans-serif; }
a { font: 1em/1.3 Times, serif, Apple Color Emoji; }
a { font: inherit; }
a { font: caption; }
a { font-family: var(--font-family-common); }
a { font-family: Helvetica, var(--font-family-common); }

可选的辅助选项

¥Optional secondary options

ignoreFontFamilies

{ "ignoreFontFamilies": ["array", "of", "font-families", "/regex/"] }

鉴于:

¥Given:

{
"font-family-no-missing-generic-family-keyword": [
true,
{
"ignoreFontFamilies": ["custom-font"]
}
]
}

以下模式不被视为问题:

¥The following pattern is not considered a problem:

a { font-family: custom-font; }

以下模式被认为是一个问题:

¥The following pattern is considered a problem:

a { font-family: invalid-custom-font; }