Skip to content

Commit

Permalink
Clarify family-name syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
wbamberg committed Jun 5, 2024
1 parent a80ebc0 commit f70f217
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions files/en-us/web/css/font-family/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ font-family: "Gill Sans Extrabold", sans-serif;
### Values

- `<family-name>`
- : The name of a font family. For example, "Times" and "Helvetica" are font families. Font family names containing whitespace should be quoted. For example: "Comic Sans MS".

- : The name of a font family. This must be either a single {{cssxref("string")}} value or a space-separated sequence of {{cssxref("custom-ident")}} values. String values must be quoted but may contain any Unicode character. Custom identifiers are not quoted, but certain characters must be escaped.

It is good practice to quote font family names that contain white space, digits, or punctuation characters other than hyphens.

See also [Valid family names](#valid_family_names).

- `<generic-name>`

- : Generic font families are a fallback mechanism, a means of preserving some of the style sheet author's intent when none of the specified fonts are available. Generic family names are keywords and must not be quoted. A generic font family should be the last item in the list of font family names. The following keywords are defined:
Expand Down Expand Up @@ -112,38 +118,6 @@ font-family: "Gill Sans Extrabold", sans-serif;
- `fangsong`
- : A particular style of Chinese characters that are between serif-style Song and cursive-style Kai forms. This style is often used for government documents.

### Valid family names

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

It is a **good practice** to quote font family names that contain white space, digits, or punctuation characters other than hyphens.

For example, the following declarations are valid:

```css example-good
font-family: "Goudy Bookletter 1911", sans-serif;
```

The following declarations are **invalid**:

```css-nolint example-bad
font-family: Goudy Bookletter 1911, sans-serif;
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;
```

The following example is technically **valid** but is not recommended:

```css
font-family:
Gill Sans Extrabold,
sans-serif;
```

## Formal definition

{{cssinfo}}
Expand Down Expand Up @@ -210,6 +184,34 @@ font-family:

{{EmbedLiveSample("Some_common_font_families", 600, 220)}}

### Valid family names

The following declarations are valid:

```css example-good
font-family: "Goudy Bookletter 1911", sans-serif;
```

The following declarations are invalid:

```css-nolint example-bad
font-family: Goudy Bookletter 1911, sans-serif;
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;
```

The following example is technically valid but is not recommended:

```css
font-family:
Gill Sans Extrabold,
sans-serif;
```

## Specifications

{{Specifications}}
Expand Down

0 comments on commit f70f217

Please sign in to comment.