CSS @styleset At-Rule
The @styleset at-rule assigns custom names to one or more OpenType stylistic sets for a font family.
It appears inside @font-feature-values and is used with font-variant-alternates: styleset().
Syntax
@font-feature-values "Alternate Font" {
@styleset {
decorative: 1 3;
}
}
The @styleset block is nested inside @font-feature-values. A descriptor maps a custom name to one or more positive integers.
How @styleset Works
The names are referenced through font-variant-alternates: styleset(). The numbers identify OpenType stylistic sets, commonly named ss01, ss02, and so on.
A named mapping is meaningful only when the selected font contains the corresponding OpenType glyph substitutions. The rule does not add glyphs to a font.
Font Requirements
The selected OpenType font must provide the requested stylistic sets. A font with no corresponding ssNN features will show its usual glyphs.
Use a real, properly licensed font with documented stylistic sets when testing.
Multiple Indexes
@font-feature-values "Alternate Font" {
@styleset {
display: 1 2 5;
subtle: 3;
}
}
A styleset descriptor can list multiple indices. This differs from @stylistic, which names a single stylistic alternate index.
Feature Names
.headline {
font-family: "Alternate Font", serif;
font-variant-alternates: styleset(display);
}
The identifier display is an author-defined label, not a built-in CSS keyword. It must match the name declared in the font-feature-values rule.
Fallback and Testing
When the font or the named feature is unavailable, ordinary glyph forms remain readable. A visual difference cannot be guaranteed using an unspecified placeholder font.
Test with the intended font and actual sample text that contains characters affected by its stylistic sets.
@styleset Example
The example names two OpenType stylistic sets and applies them to a heading.
HTML
<h2 class="sample-heading">Sample typography</h2>
CSS
@font-feature-values "Alternate Font" {
@styleset {
headline: 1 2;
}
}
.sample-heading {
font-family: "Alternate Font", serif;
font-variant-alternates: styleset(headline);
}
Preview: Replace "Alternate Font" with a font containing the relevant ss01 and ss02 features. A Browser Result without that font would be misleading.
Browser Support
Browser support varies for named font feature values and font-variant-alternates. Check Can I Use? and verify the actual font features.
Specifications
The @styleset rule is defined in CSS Fonts Module Level 4.
