CSS font-variant-alternates Property

If this site has been useful, we’d love your support! Running this site takes time and resources, and every small contribution helps us keep creating valuable content. Consider buying us a coffee to keep things going strong!

Description

The font-variant-alternates CSS property is used to control the selection of alternate glyph forms or characters within a font family. It allows web developers to specify whether a font should use its default glyph variants or alternate forms, such as ligatures, swashes, or stylistic alternates. This property can enhance typography and design by enabling custom typography effects while maintaining accessibility and legibility. By adjusting the values of this property, designers can achieve unique typographic styles that align with their creative vision, making web content more visually appealing and engaging.

Initial value
normal
Applies to
All elements
Inherited
Yes
Computed value
As specified
Animatable
No
JavaScript syntax
object.style.fontVariantAlternates

Syntax

font-variant-alternates: normal | [ stylistic(<feature-value-name>) || historical-forms || styleset(<feature-value-name> #) || character-variant(<feature-value-name> #) || swash(<feature-value-name>) || ornaments(<feature-value-name>) || annotation(<feature-value-name>) ] 

Values

  • normalNone of the features listed below are enabled.
  • stylistic(<feature-value-name>)Enables display of stylistic alternates (font specific, OpenType feature: salt <feature-index>).
  • historical-formsEnables display of historical forms (OpenType feature: hist).
  • styleset(<feature-value-name> #)Enables display with stylistic sets (font specific, OpenType feature: ss<feature-index> OpenType currently defines ss01 through ss20).
  • character-variant(<feature-value-name> #)Enables display of specific character variants (font specific, OpenType feature: cv<feature-index> OpenType currently defines cv01 through cv99).
  • swash(<feature-value-name>)Enables display of swash glyphs (font specific, OpenType feature: swsh <feature-index>, cswh ).
  • ornaments(<feature-value-name>)Enables replacement of default glyphs with ornaments, if provided in the font (font specific, OpenType feature: ornm <feature-index>).
  • annotation(<feature-value-name>)Enables display of alternate annotation forms (font specific, OpenType feature: nalt <feature-index>).

Example

<p>A Fancy Swash</p>
<p class="variant">A Fancy Swash</p>
@import url('https://fonts.googleapis.com/css2?family=MonteCarlo&display=swap');

@font-feature-values "MonteCarlo" {
  @swash {
    fancy: 1;
  }
}

p {
  font-family: "MonteCarlo";
  font-size: 3rem;
  margin: 0.7rem 3rem;
}

.variant {
  font-variant-alternates: swash(fancy);
}

Browser Support

The following table will show you the current browser support for the CSS font-variant-alternates property.

Desktop
Edge Chrome Firefox Opera Safari
11111134979.1
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview
11134X9.322111

Last updated by CSSPortal on: 31st December 2023