CSS font-variant-alternates Property
The font-variant-alternates property controls the use of alternate glyphs, including stylistic forms, swashes, ornaments, annotations, and historical letterforms.
Some fonts contain multiple designs for the same character. This property allows authors to request those designs using named font features. Most named alternates require definitions in an @font-feature-values rule and a font that supports the corresponding OpenType features.
font-variant-alternates Syntax
The property accepts normal or one or more supported alternate glyph values.
Basic Syntax
selector {
font-variant-alternates: normal;
}
Historical Forms
selector {
font-variant-alternates: historical-forms;
}
Stylistic Alternate
selector {
font-variant-alternates: stylistic(display);
}
Stylistic Set
selector {
font-variant-alternates: styleset(alternate);
}
Multiple Features
selector {
font-variant-alternates: historical-forms styleset(alternate);
}
CSS-Wide Keywords
.example {
font-variant-alternates: inherit;
}
.example {
font-variant-alternates: initial;
}
.example {
font-variant-alternates: unset;
}
.example {
font-variant-alternates: revert;
}
.example {
font-variant-alternates: revert-layer;
}
Names such as display and alternate are author-defined identifiers. They must be associated with actual font feature values through @font-feature-values.
Property Values
The following values control the alternate glyph features requested from the selected font.
| Value | Description |
|---|---|
normal |
Uses the default alternate glyph settings. |
historical-forms |
Requests historical character forms through the OpenType hist feature. |
stylistic(name) |
Requests a named stylistic alternate through the salt feature. |
styleset(name) |
Requests one or more named stylistic sets through ss01 to ss20. |
character-variant(name) |
Requests named character variants through cv01 to cv99. |
swash(name) |
Requests decorative swash forms through swsh and related features. |
ornaments(name) |
Requests decorative ornaments through the ornm feature. |
annotation(name) |
Requests alternate annotation forms through the nalt feature. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | normal |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
Each named feature is resolved using the selected font family's @font-feature-values definitions. The corresponding OpenType feature must also exist in the font for the requested alternate to appear.
How It Works
Fonts may contain multiple glyph designs for a character. The font-variant-alternates property selects optional designs through named font features.
Default Glyph
.heading {
font-variant-alternates: normal;
}
This uses the default alternate glyph settings.
Requesting an Alternate
.heading {
font-variant-alternates: styleset(display);
}
This requests the stylistic set associated with the identifier display.
Resolving the Identifier
@font-feature-values "Example Serif" {
@styleset {
display: 1;
}
}
The identifier display is associated with stylistic set 1, which corresponds to the OpenType ss01 feature.
Selecting the Font
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: styleset(display);
}
The browser uses the feature mapping when rendering text with the matching font family.
Missing Features
If the selected font lacks the requested feature or glyph, the alternate appearance may not be applied.
Important Consideration
CSS recognizes the named feature syntax independently of whether the font provides the corresponding alternate glyphs.
The normal Value
The normal value uses the default alternate glyph settings.
Basic Example
.paragraph {
font-variant-alternates: normal;
}
Reset an Alternate
.heading {
font-variant-alternates: styleset(display);
}
.heading .regular-text {
font-variant-alternates: normal;
}
Default Behavior
Because normal is the initial value, optional alternate glyph features are not requested by this property unless another value is specified.
Important Consideration
The normal value does not disable all OpenType features. Other properties and default font shaping behavior may still affect glyph selection.
Historical Forms
The historical-forms keyword requests historical glyph designs when the font provides them.
Basic Example
.historical-text {
font-variant-alternates: historical-forms;
}
Historical Heading
.historical-heading {
font-family: "Example Historical", serif;
font-variant-alternates: historical-forms;
}
OpenType Feature
The keyword corresponds to the OpenType hist feature. Unlike named alternate functions, it does not require an @font-feature-values definition.
Font Availability
Historical forms are uncommon in many everyday fonts. Fonts designed for historical typography are more likely to provide them.
Important Consideration
Historical glyph forms may reduce readability for some audiences. Use them selectively, especially in headings or decorative text.
Stylistic Alternates
The stylistic() function requests a named stylistic alternate from the selected font.
Basic Example
.heading {
font-variant-alternates: stylistic(display);
}
Define the Alternate
@font-feature-values "Example Serif" {
@stylistic {
display: 1;
}
}
Apply the Font
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: stylistic(display);
}
OpenType Feature
Stylistic alternates use the OpenType salt feature. The number assigned in @stylistic identifies the requested alternate selection.
Important Consideration
The identifier must match a definition for the selected font family. The font must provide the corresponding alternate glyph for a visible change.
Stylistic Sets
The styleset() function requests one or more named stylistic sets. A stylistic set may change the appearance of several characters together.
Basic Example
.heading {
font-variant-alternates: styleset(display);
}
Define a Stylistic Set
@font-feature-values "Example Serif" {
@styleset {
display: 1;
}
}
Multiple Named Sets
@font-feature-values "Example Serif" {
@styleset {
display: 1;
rounded: 2;
}
}
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: styleset(display, rounded);
}
OpenType Features
Stylistic sets correspond to OpenType features ss01 through ss20.
Important Consideration
Different fonts may use the same stylistic set numbers for entirely different designs. Check the font documentation before selecting a set.
Character Variants
The character-variant() function requests named alternate designs for particular characters.
Basic Example
.heading {
font-variant-alternates: character-variant(alternate);
}
Define a Character Variant
@font-feature-values "Example Serif" {
@character-variant {
alternate: 1;
}
}
Select the Variant
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: character-variant(alternate);
}
OpenType Features
Character variants correspond to OpenType features cv01 through cv99. Some features can also provide multiple alternate choices.
Important Consideration
Character variants may affect only certain letters or symbols. Text containing other characters may appear unchanged.
Swash Characters
The swash() function requests decorative letterforms with extended strokes or flourishes.
Basic Example
.decorative-heading {
font-variant-alternates: swash(decorative);
}
Define a Swash
@font-feature-values "Example Script" {
@swash {
decorative: 1;
}
}
Apply the Swash
.decorative-heading {
font-family: "Example Script", cursive;
font-variant-alternates: swash(decorative);
}
OpenType Features
Swash alternates are associated with OpenType features such as swsh and cswh.
Important Consideration
Swashes are best used sparingly. Decorative flourishes can overlap neighboring text or make longer passages difficult to read.
Ornaments
The ornaments() function requests decorative symbols or ornament glyphs provided by a font.
Basic Example
.decorative-symbol {
font-variant-alternates: ornaments(decorative);
}
Define an Ornament
@font-feature-values "Example Ornaments" {
@ornaments {
decorative: 1;
}
}
Apply the Ornament
.decorative-symbol {
font-family: "Example Ornaments", serif;
font-variant-alternates: ornaments(decorative);
}
OpenType Feature
Ornaments use the OpenType ornm feature.
Important Consideration
Ornament glyphs are font-specific. A standard text font may not contain decorative replacements for the selected characters.
Annotations
The annotation() function requests alternate annotation glyphs, such as enclosed or specially marked character forms.
Basic Example
.annotation-text {
font-variant-alternates: annotation(circled);
}
Define an Annotation
@font-feature-values "Example Symbols" {
@annotation {
circled: 1;
}
}
Apply the Annotation
.annotation-text {
font-family: "Example Symbols", sans-serif;
font-variant-alternates: annotation(circled);
}
OpenType Feature
Annotations use the OpenType nalt feature.
Important Consideration
Annotation features are not available in every font. The requested appearance depends on the glyph substitutions provided by the selected font.
Using @font-feature-values
The @font-feature-values rule associates readable identifiers with numeric OpenType feature selections for a font family.
Define Multiple Features
@font-feature-values "Example Serif" {
@stylistic {
display: 1;
}
@styleset {
alternate: 1;
rounded: 2;
}
@swash {
decorative: 1;
}
}
Apply a Named Feature
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: styleset(alternate);
}
Apply Several Features
.decorative-heading {
font-family: "Example Serif", serif;
font-variant-alternates: stylistic(display) swash(decorative);
}
Font Family Matching
The font family name in @font-feature-values must match the family used for the text.
Feature Numbers
The numeric values refer to font feature selections, not CSS font weights or sizes. The correct numbers depend on the font's OpenType feature definitions.
Important Consideration
Defining a feature name does not create alternate glyphs. The font must contain the corresponding feature and glyph substitutions.
Combining Values
Multiple alternate glyph features can be requested in one declaration when their values are compatible.
Historical Forms and Stylistic Set
.heading {
font-variant-alternates: historical-forms styleset(alternate);
}
Stylistic Alternate and Swash
.decorative-heading {
font-variant-alternates: stylistic(display) swash(decorative);
}
Stylistic Set and Character Variant
.heading {
font-variant-alternates: styleset(alternate) character-variant(rounded);
}
Multiple Stylistic Sets
.heading {
font-variant-alternates: styleset(display, rounded);
}
Invalid Combination
.heading {
font-variant-alternates: normal historical-forms;
}
This declaration is invalid because normal must be used alone.
Important Consideration
Combining feature requests does not guarantee that all effects will be visible. The selected font must provide each requested feature, and some glyph substitutions may interact.
The font-variant Shorthand
The font-variant shorthand can include alternate glyph settings alongside capitalization, ligature, and numeric features.
Longhand Example
.heading {
font-variant-alternates: historical-forms;
}
Shorthand Example
.heading {
font-variant: historical-forms;
}
Combining with Small Capitals
.heading {
font-variant: small-caps historical-forms;
}
Combining with Numeric Features
.heading {
font-variant: historical-forms oldstyle-nums;
}
Shorthand Reset Behavior
.heading {
font-variant-alternates: historical-forms;
font-variant: small-caps;
}
The later shorthand resets font-variant-alternates to its initial value because the alternate feature is not included.
Preserving Both Features
.heading {
font-variant: small-caps historical-forms;
}
Important Consideration
Use font-variant-alternates when changing only alternate glyph selection. Use the shorthand when several font variant categories should be controlled together.
Using font-feature-settings
The font-feature-settings property provides direct access to OpenType feature tags and numeric settings.
High-Level Historical Forms
.historical-text {
font-variant-alternates: historical-forms;
}
Low-Level Historical Forms
.historical-text {
font-feature-settings: "hist" 1;
}
High-Level Stylistic Set
@font-feature-values "Example Serif" {
@styleset {
alternate: 1;
}
}
.heading {
font-family: "Example Serif", serif;
font-variant-alternates: styleset(alternate);
}
Low-Level Stylistic Set
.heading {
font-feature-settings: "ss01" 1;
}
Preferred Approach
Use font-variant-alternates for readable, high-level feature selection. Use font-feature-settings when direct control over specific OpenType features is necessary.
Important Consideration
Low-level feature settings can interact with higher-level font properties. Avoid using both to control the same feature unless the interaction is intentional.
Font Support and Fallbacks
Alternate glyph features are highly dependent on the selected font.
Fonts with Alternate Glyphs
Some display, script, and decorative fonts contain stylistic sets, swashes, ornaments, or historical forms.
Fonts Without Alternate Glyphs
.heading {
font-family: Arial, sans-serif;
font-variant-alternates: historical-forms;
}
If the selected font lacks historical forms, the text may appear unchanged.
Fallback Font Example
.heading {
font-family: "Example Display", Georgia, serif;
font-variant-alternates: styleset(display);
}
If the primary font is unavailable, the fallback font may not contain the requested stylistic set.
Custom Web Fonts
When using custom fonts, check their OpenType feature documentation before creating named alternate mappings.
Testing Alternate Glyphs
Test the specific characters affected by the feature. A font may provide alternates for only a small subset of its glyphs.
Important Consideration
Browser support for the CSS property does not guarantee visible results. Both the feature mapping and the corresponding font glyphs must be available.
Inheritance
The font-variant-alternates property is inherited. Child elements receive the parent's alternate glyph settings unless they specify another value.
Inherited Setting
.decorative-section {
font-variant-alternates: historical-forms;
}
<div class="decorative-section">
<h2>Historical Typography</h2>
<p>A paragraph with inherited font variants.</p>
</div>
Override a Child Element
.decorative-section {
font-variant-alternates: historical-forms;
}
.decorative-section .regular-text {
font-variant-alternates: normal;
}
Explicit Inheritance
.child {
font-variant-alternates: inherit;
}
Reset to Initial Value
.child {
font-variant-alternates: initial;
}
Important Consideration
Inherited alternate glyph settings may affect descendant text using different fonts. A feature may be visible in one font but unavailable in another.
font-variant-alternates Example
This example demonstrates how to request historical glyph forms and a named stylistic set. The live result uses a system font, so the alternate features may not produce a visible change.
HTML Example
<div class="font-variant-alternates-demo">
<p class="demo-label">Normal glyphs</p>
<p class="normal-text">Creative Typography</p>
<p class="demo-label">Historical forms</p>
<p class="historical-text">Creative Typography</p>
<p class="demo-label">Stylistic set</p>
<p class="styleset-text">Creative Typography</p>
</div>
CSS Example
@font-feature-values Georgia {
@styleset {
alternate: 1;
}
}
.font-variant-alternates-demo {
font-family: Georgia, serif;
}
.font-variant-alternates-demo p {
margin: 0 0 16px;
}
.font-variant-alternates-demo .demo-label {
font: 600 13px/1.4 Arial, sans-serif;
}
.font-variant-alternates-demo .normal-text,
.font-variant-alternates-demo .historical-text,
.font-variant-alternates-demo .styleset-text {
font-size: 28px;
line-height: 1.4;
}
.normal-text {
font-variant-alternates: normal;
}
.historical-text {
font-variant-alternates: historical-forms;
}
.styleset-text {
font-variant-alternates: styleset(alternate);
}
Normal glyphs
Creative Typography
Historical forms
Creative Typography
Stylistic set
Creative Typography
The first line uses the default glyph forms. The second requests historical forms, while the third requests stylistic set 1 through the name alternate.
The text may look identical because Georgia does not necessarily provide the requested OpenType features. To demonstrate visible alternates, replace Georgia with a font that supports historical forms or stylistic set 1 and update the feature mapping to match that font.
Common Mistakes
The most common mistakes involve missing feature definitions, unsupported font features, or invalid value combinations.
Using an Undefined Name
.heading {
font-variant-alternates: styleset(display);
}
This declaration requires a matching @styleset definition for the selected font family. Without that mapping, the named feature cannot be resolved.
Using a Number Directly
.heading {
font-variant-alternates: styleset(1);
}
This syntax is invalid. Use a named identifier defined through @font-feature-values.
Combining normal with Another Value
.heading {
font-variant-alternates: normal historical-forms;
}
The normal keyword must be used alone.
Using a Font Without the Feature
A valid declaration may have no visible effect when the selected font does not provide the requested alternate glyphs.
Using the Wrong Font Family Name
@font-feature-values "Example Serif" {
@styleset {
display: 1;
}
}
.heading {
font-family: "Different Serif", serif;
font-variant-alternates: styleset(display);
}
The named mapping applies to Example Serif, not Different Serif.
Assuming the Feature Name Has a Built-In Meaning
Identifiers such as display, alternate, and decorative are author-defined. They do not automatically activate a specific OpenType feature.
Confusing Stylistic Sets with Character Variants
Stylistic sets may affect multiple glyphs, while character variants commonly provide alternate designs for particular characters.
Ignoring Shorthand Reset Behavior
A later font-variant declaration can reset font-variant-alternates to its initial value.
Assuming Feature Detection Confirms Font Support
The @supports rule can detect CSS syntax support, but it cannot confirm that the selected font contains the requested glyphs.
Important Considerations
Keep the following points in mind when using the font-variant-alternates property:
- Purpose: Selects alternate glyph designs provided by a font.
- Property type: Longhand of
font-variant. - Initial value:
normal. - Inheritance: The property is inherited.
- Applies to: All elements and text.
- normal: Uses default alternate glyph settings.
- historical-forms: Requests historical glyph designs.
- stylistic(): Requests named stylistic alternates.
- styleset(): Requests named stylistic sets.
- character-variant(): Requests named character variants.
- swash(): Requests decorative swash letterforms.
- ornaments(): Requests ornament glyphs.
- annotation(): Requests annotation glyph forms.
- @font-feature-values: Defines names for alternate feature selections.
- Font family: Named feature definitions must match the selected font family.
- OpenType: Most alternate features depend on OpenType glyph substitutions.
- Font support: A valid CSS declaration does not guarantee a visible alternate.
- Fallback fonts: Different fonts may provide different feature selections.
- Shorthand reset: A later
font-variantdeclaration may reset the property. - Accessibility: Decorative glyphs should not make important text difficult to read.
- Browser support: Check compatibility for named alternate features and
@font-feature-values.
Use font-variant-alternates when a font provides alternate glyph designs that improve the intended typography. Verify the font's feature mappings and test the actual characters before relying on the effect.
Browser Support
The CSS font-variant-alternates property has modern browser support, but compatibility varies by browser version and individual feature. Older browsers may not recognize the property or its named alternate functions.
Support for @font-feature-values is also important because named alternates depend on its feature mappings.
Basic Example
.historical-text {
font-variant-alternates: historical-forms;
}
Feature Detection
@supports (font-variant-alternates: historical-forms) {
.historical-text {
font-variant-alternates: historical-forms;
}
}
Named Alternate Detection
@supports (font-variant-alternates: styleset(display)) {
.heading {
font-variant-alternates: styleset(display);
}
}
Fallback Using font-feature-settings
.heading {
font-feature-settings: "ss01" 1;
}
@supports (font-variant-alternates: styleset(display)) {
.heading {
font-variant-alternates: styleset(display);
}
}
This example illustrates a low-level fallback. It assumes the font uses stylistic set 1 for the intended design and that the named mapping has been defined separately.
Important Consideration
Feature detection checks whether the browser recognizes the CSS syntax. It does not confirm that the font contains the requested OpenType features.
For current compatibility information, visit Can I Use? and search for font-variant-alternates.
Specifications
The font-variant-alternates property is defined in the CSS Fonts Module, which describes alternate glyph selection and named font feature values.
CSS Fonts Module Level 4: font-variant-alternates
The module also defines @font-feature-values, related font variant properties, and the mapping between CSS font features and OpenType features.
For additional explanations and examples, see MDN Web Docs.
