`@font-feature-values` CSS at-rule
Baseline Widely available
This feature is well established and works across many devices and browser versions. It's been available across browsers since March 2023.
The @font-feature-values CSS at-rule lets you use a common name in the font-variant-alternates property for features activated differently in OpenType. This can help simplify your CSS when using multiple fonts.
The @font-feature-values at-rule may be used either at the top level of your CSS or inside any CSS conditional-group at-rule.
Syntax
@font-feature-values Font Name {
font-display: swap;
@styleset {
nice-style: 12;
}
@swash {
fancy: 2;
}
}
Each @font-feature-values block can contain a list of feature value blocks (listed below), as well as the font-display descriptor.
Feature value blocks
-
@swash - Specifies a feature name that will work with the
swash()functional notation offont-variant-alternates. A swash feature value definition allows only one value:ident1: 2is valid, butident2: 2 4isn't. -
@annotation - Specifies a feature name that will work with the
annotation()functional notation offont-variant-alternates. An annotation feature value definition allows only one value:ident1: 2is valid, butident2: 2 4isn't. -
@ornaments - Specifies a feature name that will work with the
ornaments()functional notation offont-variant-alternates. An ornaments feature value definition allows only one value:ident1: 2is valid, butident2: 2 4isn't. -
@stylistic - Specifies a feature name that will work with the
stylistic()functional notation offont-variant-alternates. A stylistic feature value definition allows only one value:ident1: 2is valid, butident2: 2 4isn't. -
@styleset - Specifies a feature name that will work with the
styleset()functional notation offont-variant-alternates. A styleset feature value definition allows an unlimited number of values:ident1: 2 4 12 1maps to the OpenType valuesss02,ss04,ss12, andss01. Note that values higher than99are valid, but don't map to any OpenType values and are ignored. -
@character-variant - Specifies a feature name that will work with the
character-variant()functional notation offont-variant-alternates. A character-variant feature value definition allows either one or two values:ident1: 3maps tocv03=1, andident2: 2 4maps tocv02=4, butident2: 2 4 5is invalid.
Formal syntax
Examples
Using @styleset in a @font-feature-values rule
/* At-rule for "nice-style" in Font One */
@font-feature-values Font One {
@styleset {
nice-style: 12;
}
}
/* At-rule for "nice-style" in Font Two */
@font-feature-values Font Two {
@styleset {
nice-style: 4;
}
}
/* Apply the at-rules with a single declaration */
.nice-look {
font-variant-alternates: styleset(nice-style);
}
Specifications
| Specification |
|---|
| CSS Fonts Module Level 4 # font-feature-values |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on iOS | Samsung Internet | WebView Android | WebView on iOS | |
font-feature-values |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
annotation |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
character-variant |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
historical-forms |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
ornaments |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
styleset |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
stylistic |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
swash |
111 |
111 |
34 |
97 |
9.1 |
111 |
34 |
75 |
9.3 |
22.0 |
111 |
9.3 |
See also
- The
font-variant-alternatesproperty that uses values that this at-rule defines.
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/At-rules/@font-feature-values