Favorites

character-variant() CSS Function

character-variant()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The character-variant() function selects character variants of a font (OpenType cvXX), such as an alternative a or g, with font-variant-alternates.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

Description

The character-variant() CSS function is one of the functions used with the font-variant-alternates property to switch on alternative glyphs in an OpenType font. It enables character variants: alternative forms for one specific character, such as a slashed zero or an alternative "l". It maps to the OpenType cv01 to cv99 features, and each variant feature can offer several glyph choices.

The argument is not a number but a name that you define yourself in a @font-feature-values rule for the font family, inside a @character-variant block. That rule maps the friendly name to the numeric index the font uses, so the same name can mean different glyph sets in different fonts. If the font has no matching feature, or no name is defined, the text is shown with its normal glyphs.

In the @character-variant block, a name maps to one or two numbers: the character variant feature, and optionally which of its glyphs to use. Several names can be given, separated by commas.

@font-feature-values "JetBrains Mono" {
  @character-variant {
    slashed-zero: 4;
    alt-l: 1 2;      /* cv01, second alternate */
  }
}

code {
  font-family: "JetBrains Mono", monospace;
  font-variant-alternates: character-variant(slashed-zero, alt-l);
}

Syntax

character-variant() = character-variant( <feature-value-name># )

Values

  • <feature-value-name>A <custom-ident> defined in the @character-variant block of an @font-feature-values rule for the font family. It maps to the font's OpenType cvXX (character variants) feature. Several comma-separated names can be given.

Example

<div class="wrap">
<h1>CSS character-variant() examples</h1>
<div class="grid">
<div class="card">
<p class="sample">Quick Brown Fox 1234</p>
<div class="label">normal glyphs</div>
</div>
<div class="card">
<p class="sample alt">Quick Brown Fox 1234</p>
<div class="label">font-variant-alternates: character-variant(fancy)</div>
</div>
</div>
<p class="note">The second sample only changes with a font that has cvXX (character variants) alternates.</p>
</div>
/* Base demo layout */
* { box-sizing: border-box; }

body {
margin: 24px;
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
background: #f5f7fb;
color: #102a43;
}

.wrap {
max-width: 860px;
margin: 0 auto;
}

h1 {
font-size: 20px;
margin: 0 0 16px;
}

.grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
gap: 16px;
}

.card {
background: #fff;
border-radius: 12px;
padding: 16px;
box-shadow: 0 6px 18px rgba(16, 42, 67, 0.08);
}

.label {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
margin-top: 10px;
word-break: break-word;
}

.note {
font-size: 13px;
color: #486581;
margin-top: 14px;
}

/* character-variant() examples */
/* Alternates only show with a font that contains them, such as many
professional OpenType fonts. With system fonts the text looks normal. */
@font-feature-values "Demo Font", Georgia {
@character-variant {
fancy: 1;
}
}

.sample {
font-family: "Demo Font", Georgia, serif;
font-size: 30px;
margin: 0;
}

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

code {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
font-size: 12px;
color: #486581;
}
Open in editor

Browser Support

The following information will show you the current browser support for the CSS character-variant() function. Hover over a browser icon to see the version that first introduced support for this CSS function.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.