Since March 2025, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
* Some parts of this feature may have varying levels of support.
The CSSFontFeatureValuesRule interface represents an @font-feature-values at-rule, letting developers assign for each font face a common name to specify features indices to be used in font-variant-alternates.
Inherits properties from its ancestor CSSRule.
CSSFontFeatureValuesRule.fontFamilyA string that identifies the font family this rule applies to.
Inherits methods from its ancestor CSSRule.
In this example, we declare two @font-feature-values one for the Font One font family, and the other for Font Two. We then use the CSSOM to read these font families, displaying them into the log.
<pre id="log"></pre>
/* 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);
}
const log = document.getElementById("log");
const rules = document.styleSheets[document.styleSheets.length - 1].cssRules;
const fontOne = rules[0]; // A CSSFontFeatureValuesRule
log.textContent = `The 1st '@font-feature-values' family: "${fontOne.fontFamily}".\n`;
const fontTwo = rules[1]; // Another CSSFontFeatureValuesRule
log.textContent += `The 2nd '@font-feature-values' family: "${fontTwo.fontFamily}".`;
| Specification |
|---|
| CSS Fonts Module Level 4> # cssfontfeaturevaluesrule> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
CSSFontFeatureValuesRule |
134 | 134 | 34 | 119 | 16.2 | 134 | 34 | 88 | 16.2 | 134 | 16.2 | |
annotation |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
characterVariant |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
fontFamily |
111 | 111 | 34 | 97 | 16.2 | 111 | 34 | 75 | 16.2 | 22.0 | 111 | 16.2 |
ornaments |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
styleset |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
stylistic |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
swash |
111 | 111 | No | 97 | No | 111 | No | 75 | No | 22.0 | 111 | No |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/CSSFontFeatureValuesRule