Font-variant-alternates - CSS Property
Summary of characteristics of the font-variant-alternates property
normal | historical-forms | annotation(nalt) | character-variant(cv01) | ornaments(ornm) | styleset(ss01) | stylistic(styl) | swash(swsh)normalDiscrète: during an animation, the font-variant-alternates property passes from one value to another without transition.Per grammar: serialization in the order of syntax. Values can be entered in any order.Syntax diagram of font-variant-alternates.
font-variant-alternates property.The links in the diagram provide more details about the values.
Download the diagram.
Description of the font-variant-alternates property.
Many fonts often offer several glyphs for each character. There’s the standard glyph, but also the decorated variant, the historical version,
the stylistic version, etc. font-variant-alternates lets you choose which variant should be used.
Unfortunately, there's no rule that requires the naming or ordering of these variants in a font. So you can't really write a CSS rule to select variant number 1 or variant number 3, because from one font to another, these variants, if they exist, wouldn't necessarily be equivalent.
For this reason, font-variant-alternates works in collaboration with the @font-feature-values directive:
@font-feature-valuesname the variants you want to use by indicating their family and their location in the chosen font.font-variant-alternatesapply these named variants to the elements of the HTML document.
The variants are still grouped by families: historical, decorative, stylistic, etc. The best thing is to explain all that with an example.
In the code below, the first directive @font-face shows the name of the font (Countryside) and where to download it.
The second directive (@font-feature-values) indicates that, for this font Countryside, the variant we call
loops is the first of the swash family variants.
Finally, the property font-variant-alternates is used to apply this loops variant to the element with the ID id1.
@font-face{
font-family:'Countryside';
src:url('fonts/countryside.ttf');
}
@font-feature-values Countryside {
@swash {loops: 1;}
}
#id1 {
font-family: 'Countryside', fantasy;
font-variant-alternates: swash(loops);
}
Which gives the result below (ultimately quite hard to read 😉 but without a doubt with some nice loops).
To complete these explanations, refer to the pages on the @font-face and 
@font-feature-values directives.

Values for font-variant-alternates.
- font-variant-alternates: normal;
Default value. No typographic processing is done. The glyphs of standard characters are used.
Test.font-family:Warnrock;
font-variant-alternates:normal; - font-variant-alternates: historical-forms;
Activate the historical variant. These are usually characters whose shapes resemble old printing typefaces. Note that there’s no need to specify the name of the historical variant here, so a declaration with
@font-feature-valuesisn’t necessary.This syntax is equivalent to
font-feature-settings:'hist'.In the
Warnockfont used for the example, only the lowercasesis changed.Test.font-family:Warnrock;
font-variant-alternates:normal;Test.font-family:Warnrock;
font-variant-alternates:historical-forms; - font-variant-alternates: annotation(id);
Activate one of the variants of the
annotationfamily, the one whose name was set toidby@font-feature-values.Variants of the
annotationtype are characters that can be used for numbering (letters or numbers surrounded, for example).The same effect can be achieved with the property
font-feature-settings:'nalt'.The font
GotichA1used in the example only includes the first 4 digits in theannotationvariant.1 2 3 4font-family:GothicA1;
font-variant-alternates:normal;1 2 3 4font-family:GothicA1;
font-variant-alternates:annotation(…); - font-variant-alternates: character-variant(id);
Activates one of the variants from the
character-variantfamily, the one whose name was set toidby@font-feature-values.These variants generally allow you to display specific characters, for example to make them easier to type when they're not accessible on the keyboard. This corresponds to the OpenType codes
cv01,cv02, etc.The same effect can be achieved with the
font-feature-settings:'cv01'property (orcv02,cv03, etc., up tocv99).We don't have any fonts that include a
character-variant(…)option: the example doesn't work.Sample.font-family:Warnrock;
font-variant-alternates:normal;Sample.font-family:Warnrock;
font-variant-alternates:character-variant(…); - font-variant-alternates: ornaments(id);
Activate one of the variants from the
ornamentsfamily, the one whose name defined by@font-feature-valuesisid.Ornaments are graphic elements like fleurons, lines, bullets, etc. Some fonts offer a whole list of ornaments to spice up a design.
Ornaments can also be displayed with the property
font-feature-settings:'ornm'.a b c d e f g hfont-family:Warnrock;
font-variant-alternates:normal;a b c d e f g hfont-family:Warnrock;
font-variant-alternates:ornaments(…); - font-variant-alternates: styleset(id);
Activates one of the variants of the
stylesetfamily, the one whose name defined by@font-feature-valuesisid.The
stylesetvariants can also be displayed with the propertyfont-feature-settings:'ss01'(orss02,ss03, etc. up toss20).To find an example that looks visually different, we had to choose the words. Indeed, few characters change between
normalandstyleset(ss01).This is the fabric.font-family:Comic-Jens;
font-variant-alternates:normal;This is the fabric.font-family:Comic-Jens;
font-variant-alternates:styleset(…); - font-variant-alternates: stylistic(id);
Activate the variants of the
stylisticfamily, whose name defined by@font-feature-valuesisid.These variants can also be displayed with the property
font-feature-settings:'ss01'.This is the fabric.font-family:Comic-Jens;
font-variant-alternates:normal;This is the fabric.font-family:Comic-Jens;
font-variant-alternates:stylistic(…); - font-variant-alternates: swash(id);
Activates the swash family variants, whose name defined by
@font-feature-valuesisid.These variants usually correspond to very ornate characters, with extra loops, hooks, etc.
Ornamental variants can also be displayed with
font-feature-settings:'swsh'.Sample.font-family:Countryside;
font-variant-alternates:normal;Sample.font-family:Countryside;
font-variant-alternates:swash(…); - font-variant-alternates: swash(id) stylistic(id);
As you can see in this syntax example, it's possible to combine several variants by separating them with a space.
- font-variant-alternates: initial; (
normal) font-variant-alternates: inherit; font-variant-alternates: revert; font-variant-alternates: revert-layer; font-variant-alternates: revert-rule; font-variant-alternates: unset;Links to the presentation of these different values:
initial,inherit,revert,revert-layer,revert-rule,unset.
Animation of the font-variant-alternates property.
The box below shows what the animation of font-variant-alternates looks like. The effect is actually more interesting when the animation happens
between two very similar variants.
Simulator.
The simulator activates the alternate glyphs of the font, as long as they exist.
All the identifiers (ann, char, hist, etc.) were defined by a @font-feature-values directive
for each of the fonts.
| Font | Countryside | Warnock | Comic-Jens |
|---|---|---|---|
| Historical | X | X | |
| Annotation | |||
| Character... | |||
| Ornaments | X | ||
| Styleset | X | ||
| Stylistic | X | X | |
| Swash | X | X |
Browsers compatibility with font-variant-alternates.
Support for the font-variant-alternates property is now correct on the major current browsers. However, keep in mind that font-variant-alternates
can only use the capabilities of the chosen font, and the variants offered in fonts aren't that many.
Notes:
(1) Use the low-level property font-feature-settings with the codes salt, ss01 to ss20, swsh, etc.
font-variant-alternatesproperty
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Firefox

Safari

Safari sur IOS

Chrome

Opéra

Edge

Chrome pour Androïd

Firefox pour Androïd

Androïd Brower

KaiOS Browser

Opéra mini
Historic of the font-variant-alternates property.
-
CSS Fonts Module Level 4
This level 4 of the specification on fonts reprises what is defined in level 3. It adds the possibility to define what happens when a font takes a long time to load or is missing. It also adds support for colored fonts and clarifies many points still poorly defined in level 3.
Regardingfont-variant-alternates:
First presentation of thefont-variant-alternatesproperty.July 11, 2017Working Draft.
See also abor fonts.
The property font-variant-alternates, along with all those related to fonts, is grouped in the module CSS Fonts Module.
You can find the following definitions in this module:
Properties:






em, ex, etc.








Functions:

At-rules:



Descriptors :

@font-face. Sets the height of the characters above the baseline.

@font-face. Sets the height of the characters below the baseline.

@font-face. Determines how the browser behaves when faced with fonts that take a long time to load.

@font-face. Sets the line spacing of the font.

@font-face. Defines the range of character codes to be downloaded into a font.


