font

@font-feature-values

Defines human-readable names for OpenType feature indices belonging to a specific font family, so authors can activate them via font-variant-alternates. It bridges obscure OpenType tag numbers to memorable identifiers.

@font-feature-values <family> { @<feature-type> { <name>: <index>; } }

Common conditions / descriptors

Descriptor Purpose
@styleset Named alternates activated with font-variant-alternates: styleset(name)
@stylistic Single-glyph stylistic alternates
@character-variant Per-glyph character variants
@swash Swash alternates for scripts
@ornaments Ornament glyph set
@annotation Annotation forms like circled digits

Examples

@font-feature-values 'Fira Code' {
  @styleset { alt-zero: 1; alt-a: 2; }
}
code { font-variant-alternates: styleset(alt-zero, alt-a); }

Name two stylistic sets and enable both on code blocks

@font-feature-values 'Recursive' {
  @character-variant { code-zero: 1; }
}
.mono { font-variant-alternates: character-variant(code-zero); }

Turn on a slashed-zero character variant

@font-feature-values 'Playfair Display' {
  @swash { fancy: 1; }
}
h1 { font-variant-alternates: swash(fancy); }

Enable swash caps on display headings

@supports (font-variant-alternates: styleset(x)) {
  code { font-variant-alternates: styleset(alt-zero); }
}

Feature-detect before shipping alternates in production

Gotcha

The family name in @font-feature-values must match the font-family string exactly for the mapping to activate. Support is limited outside Safari and recent Chromium — always feature-detect and provide a neutral fallback.

Related at-rules

← All CSS at-rules · CSS properties · CSS selectors