1. 程式人生 > >font property font-family does not have generic default?

font property font-family does not have generic default?

https 擁有 keywords cte 列名 sign character 字體 ant

在 CSS 中,有兩種不同類型的字體系列名稱:

  • 通用字體系列(generic family name) - 擁有相似外觀的字體系統組合(比如 "Serif" 或 "Monospace")
  • 特定字體系列(font family name) - 具體的字體系列(比如 "Times" 或 "Courier")

除了各種特定的字體系列外,CSS 定義了 5 種通用字體系列:

  • Serif 字體
  • Sans-serif 字體
  • Monospace 字體
  • Cursive 字體
  • Fantasy 字體

font property font-family does not have generic default 是編輯器在提醒我們CSS font-famiy

需要配置用來 fallback 的 generic-name

原文如下(鏈接https://www.w3.org/TR/CSS21/fonts.html#generic-font-families):

Style sheet designers are encouraged to offer a generic font family as a last alternative. Generic font family names are keywords and must NOT be quoted.

Font family names must either be given quoted as strings, or unquoted as a sequence of one or more identifiers. This means most punctuation characters and digits at the start of each token must be escaped in unquoted font family names.

For example, the following declarations are invalid:

font-family: Red/Black, sans-serif;
font-family: "Lucida" Grande, sans-serif;
font-family: Ahem!, sans-serif;
font-family: test@foo, sans-serif;
font-family: #POUND, sans-serif;
font-family: Hawaii 5-0, sans-serif;

If a sequence of identifiers is given as a font family name, the computed value is the name converted to a string by joining all the identifiers in the sequence by single spaces.

To avoid mistakes in escaping, it is recommended to quote font family names that contain white space, digits, or punctuation characters other than hyphens:

body { font-family: "New Century Schoolbook", serif }

<BODY STYLE="font-family: ‘21st Century‘, fantasy">

Font family names that happen to be the same as a keyword value (‘inherit‘, ‘serif‘, ‘sans-serif‘, ‘monospace‘, ‘fantasy‘, and ‘cursive‘) must be quoted to prevent confusion with the keywords with the same names. The keywords ‘initial‘ and ‘default‘ are reserved for future use and must also be quoted when used as font names. UAs must not consider these keywords as matching the ‘<family-name>‘ type.

font property font-family does not have generic default?