Baseline 2025 *
Newly available
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.fontFamily
A 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.
/* 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);
}
JavaScript
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}".`;
Specifications Browser compatibility See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4