Support0

CSS font-variant playground

Explore font-variant with controls for caps, ligatures, numeric variants, east-asian forms, and position on a real text block.

Ask AI

CSS font-variant playground

Response generated with openai/gpt-5.4-nano. AI can make mistakes. Always review the result.

BaselineLab compares font-variant with real text: Office affinity, efficient flow. Try digits 1234567890, fractions 1/2 and 3/4, and ordinals 1st and 2nd. The result depends on the OpenType variants available in the font.

HTML
<p class="font-variant-sample">
  BaselineLab compares font-variant with real text: Office affinity, efficient flow.
  Try digits 1234567890, fractions 1/2 and 3/4, and ordinals 1st and 2nd.
  The result depends on the OpenType variants available in the font.
</p>
Tailwind CSS
Examples for Tailwind CSS 4.3 with the default theme. Custom values keep arbitrary classes when there is no equivalent utility. Changing the theme can change utility values.
<p class="max-w-2xl [font-family:Georgia,_Cambria,_Times_New_Roman,_Times,_serif] text-2xl font-semibold leading-normal [font-variant:small-caps_common-ligatures_oldstyle-nums_tabular-nums_diagonal-fractions_ordinal]">
  BaselineLab compares font-variant with real text: Office affinity, efficient flow.
  Try digits 1234567890, fractions 1/2 and 3/4, and ordinals 1st and 2nd.
  The result depends on the OpenType variants available in the font.
</p>
CSS
.font-variant-sample {
  max-inline-size: 40rem;
  font-family: Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 1.55rem;
  font-weight: 600;
  line-height: 1.45;
  font-variant: small-caps common-ligatures oldstyle-nums tabular-nums diagonal-fractions ordinal;
}

Educational guide to font-variant

Choosing variants for readable text and numbers

Combine small capitals, ligatures and numeric variants. Understand East Asian forms and typographic positioning without mistaking accepted syntax for font capabilities.

Mental model

font-variant requests alternative glyph forms. It does not change text characters or select a new family. The result depends on font features, language and active rules; some variants allow synthesis when dedicated outlines are missing.

  1. Express an intention

    Request small capitals, tabular figures or a typographic position.

  2. Consult the font

    Resolve the available features for those characters and their language.

  3. Lay out and read

    Review outlines, metrics and the readability of the result.

From text to glyphsStatic diagram. A computed value or CSS.supports confirms the request or syntax, not the existence of alternate glyphs in the file being used.

Compose without accidental resets

The shorthand replaces the set of variants: omitted subproperties return to their initial values. Use longhands to change one family without clearing the others. Variants are inherited.

One inherited base, two ways to add ligatures

Inherits small-caps and tabular figures

Atlas of Typography · 0123456789

Shorthand · resets omitted variants

Atlas of Typography · 0123456789

Longhand · keeps the other inherited variants

Atlas of Typography · 0123456789

The second row loses the small capitals and figures requested by the parent. The third changes only ligatures and keeps the rest. Visible differences depend on the font; the declarations show the reset even when numbers look identical.
One inherited base, two ways to add ligatures
<div class="font-variant-guide-composition">
  <div>
    <p class="label">Inherits small-caps and tabular figures</p>
    <p class="sample inherited">Atlas of Typography · 0123456789</p>
  </div>
  <div>
    <p class="label">Shorthand · resets omitted variants</p>
    <p class="sample reset">Atlas of Typography · 0123456789</p>
  </div>
  <div>
    <p class="label">Longhand · keeps the other inherited variants</p>
    <p class="sample preserved">Atlas of Typography · 0123456789</p>
  </div>
</div>
.font-variant-guide-composition {
  font-variant: small-caps lining-nums tabular-nums;
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .reset {
    font-variant: common-ligatures;
  }

  .preserved {
    font-variant-ligatures: common-ligatures;
  }
}

normal resets the subproperties to normal; none sets ligatures to none and the others to normal. Neither means “remove every font feature”. In a list, do not combine normal/none with other variants or mutually exclusive options such as lining-nums oldstyle-nums: the entire declaration would be invalid.

The playground covers caps, ligatures, numeric, east-asian and position. The current specification also includes alternates and emoji in the shorthand; check their support separately. The custom selector is a lab mode, not a CSS value. font-variant does not replace font-style, font-weight or font-stretch.

Small capitals and capital variants

small-caps uses small capitals for lowercase letters; all-small-caps also affects uppercase letters. These are typographic forms, not an uppercase conversion of the text. The original spelling remains available when copied.

The same phrase, three treatments

font-variant-caps: normal

Atlas of Typography

font-variant-caps: small-caps

Atlas of Typography

font-variant-caps: all-small-caps

Atlas of Typography

Compare initials and the remaining letters. Georgia or serif may provide outlines or synthesis: this scene does not certify designed small capitals. When the required features are missing, results can vary or look identical.
The same phrase, three treatments
<div class="font-variant-guide-caps">
  <div>
    <p class="label">font-variant-caps: normal</p>
    <p class="sample variant-0">Atlas of Typography</p>
  </div>
  <div>
    <p class="label">font-variant-caps: small-caps</p>
    <p class="sample variant-1">Atlas of Typography</p>
  </div>
  <div>
    <p class="label">font-variant-caps: all-small-caps</p>
    <p class="sample variant-2">Atlas of Typography</p>
  </div>
</div>
.font-variant-guide-caps {
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .variant-0 {
    font-variant-caps: normal;
  }

  .variant-1 {
    font-variant-caps: small-caps;
  }

  .variant-2 {
    font-variant-caps: all-small-caps;
  }
}

petite-caps/all-petite-caps request smaller capitals; unicase mixes forms of a single height and titling-caps requests title variants. Differences depend on the font. Browsers may synthesize small capitals; font-synthesis: none can prevent this when evaluating real outlines. Avoid long paragraphs in small capitals and retain strong/em for semantic emphasis.

Ligatures and contextual alternates

A ligature can represent several characters with one combined outline. common-ligatures and no-common-ligatures control common ones, such as fi or fl when offered by the font. No ligature characters are inserted into the HTML.

Letter pairs with and without common ligatures

font-variant-ligatures: normal

office · affinity · difficult · fi fl ffi

font-variant-ligatures: no-common-ligatures

office · affinity · difficult · fi fl ffi

font-variant-ligatures: common-ligatures discretionary-ligatures

office · affinity · difficult · fi fl ffi

All three rows contain exactly the same characters. Look for the fi/fl joins; the third also requests discretionary ligatures, without inventing any missing from the font.
Letter pairs with and without common ligatures
<div class="font-variant-guide-ligatures">
  <div>
    <p class="label">font-variant-ligatures: normal</p>
    <p class="sample variant-0">office · affinity · difficult · fi fl ffi</p>
  </div>
  <div>
    <p class="label">font-variant-ligatures: no-common-ligatures</p>
    <p class="sample variant-1">office · affinity · difficult · fi fl ffi</p>
  </div>
  <div>
    <p class="label">font-variant-ligatures: common-ligatures discretionary-ligatures</p>
    <p class="sample variant-2">office · affinity · difficult · fi fl ffi</p>
  </div>
</div>
.font-variant-guide-ligatures {
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .variant-0 {
    font-variant-ligatures: normal;
  }

  .variant-1 {
    font-variant-ligatures: no-common-ligatures;
  }

  .variant-2 {
    font-variant-ligatures: common-ligatures discretionary-ligatures;
  }
}

normal usually enables common ligatures and contextual alternates, leaving discretionary and historical ligatures disabled. discretionary-ligatures, historical-ligatures and contextual have no-* counterparts. none disables these categories but does not remove ligatures required by a writing system. Avoid disabling typographic features globally to resolve an isolated case.

Figures for text, amounts and fractions

Figure style and spacing are independent choices: lining-nums aligns figures by height; oldstyle-nums allows ascenders and descenders. proportional-nums uses variable widths; tabular-nums requests the same advance width for every digit.

Compare 11111 and 88888 at the same size

font-variant-numeric: lining-nums proportional-nums

11111
88888
0123456789

font-variant-numeric: lining-nums tabular-nums

11111
88888
0123456789

font-variant-numeric: oldstyle-nums proportional-nums

11111
88888
0123456789

Local features · diagonal-fractions / ordinal / slashed-zero

1/2 · 1st · 0O

When tabular figures are available, both five-digit strings occupy the same width. The last row applies fraction, ordinal and slashed zero to separate runs; 1st is marked as English. Accepted values do not guarantee that system-ui provides all these forms.
Compare 11111 and 88888 at the same size
<div class="font-variant-guide-numeric">
  <div>
    <p class="label">font-variant-numeric: lining-nums proportional-nums</p>
    <p class="sample variant-0">11111<br>88888<br>0123456789</p>
  </div>
  <div>
    <p class="label">font-variant-numeric: lining-nums tabular-nums</p>
    <p class="sample variant-1">11111<br>88888<br>0123456789</p>
  </div>
  <div>
    <p class="label">font-variant-numeric: oldstyle-nums proportional-nums</p>
    <p class="sample variant-2">11111<br>88888<br>0123456789</p>
  </div>
  <div>
    <p class="label">Local features · diagonal-fractions / ordinal / slashed-zero</p>
    <p class="sample"><span class="fraction">1/2</span> · <span class="ordinal" lang="en">1st</span> · <span class="zero">0O</span></p>
  </div>
</div>
.font-variant-guide-numeric {
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .sample {
    font-family: system-ui, sans-serif;
  }

  .variant-0 {
    font-variant-numeric: lining-nums proportional-nums;
  }

  .variant-1 {
    font-variant-numeric: lining-nums tabular-nums;
  }

  .variant-2 {
    font-variant-numeric: oldstyle-nums proportional-nums;
  }

  .fraction {
    font-variant-numeric: diagonal-fractions;
  }

  .ordinal {
    font-variant-numeric: ordinal;
  }

  .zero {
    font-variant-numeric: slashed-zero;
  }
}

For amount columns, combine lining-nums tabular-nums with end alignment and consistent decimal formatting: tabular-nums alone does not align separators, signs or amounts of different lengths. diagonal-fractions and stacked-fractions are alternatives; scope them to the fraction to avoid shrinking other figures. They do not create accessible mathematical structure. ordinal and slashed-zero do not change the original characters.

East Asian forms and widths

jis78/jis83/jis90/jis04 request Japanese variants; simplified/traditional request glyph forms. They do not translate text or convert its encoding. Choose the right language and content before adjusting presentation.

A Japanese sample and its widths

font-variant-east-asian: normal

骨 直 令 · アイウ · ABC 123

font-variant-east-asian: jis04 full-width

骨 直 令 · アイウ · ABC 123

font-variant-east-asian: proportional-width

骨 直 令 · アイウ · ABC 123

The text has lang="ja" and requests a local Japanese font with sans-serif fallback. full-width requests full-width metrics; proportional-width requests proportional metrics. There may be no difference if the font rendering each character lacks the feature.
A Japanese sample and its widths
<div class="font-variant-guide-east-asian">
  <div>
    <p class="label">font-variant-east-asian: normal</p>
    <p class="sample variant-0" lang="ja">骨 直 令 · アイウ · ABC 123</p>
  </div>
  <div>
    <p class="label">font-variant-east-asian: jis04 full-width</p>
    <p class="sample variant-1" lang="ja">骨 直 令 · アイウ · ABC 123</p>
  </div>
  <div>
    <p class="label">font-variant-east-asian: proportional-width</p>
    <p class="sample variant-2" lang="ja">骨 直 令 · アイウ · ABC 123</p>
  </div>
</div>
.font-variant-guide-east-asian {
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .sample {
    font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
  }

  .variant-0 {
    font-variant-east-asian: normal;
  }

  .variant-1 {
    font-variant-east-asian: jis04 full-width;
  }

  .variant-2 {
    font-variant-east-asian: proportional-width;
  }
}

One form variant, one width variant and ruby can be combined. The ruby value requests glyphs suitable for small annotations; it creates no annotations and does not replace ruby/rt elements. The playground selects one value at a time; the example combines jis04 full-width to teach composition without expanding the controls.

Subscripts and superscripts with meaning

Keep sub and sup in HTML to express subscript or superscript meaning. font-variant-position: sub/super requests smaller, shifted glyphs within the font box; it does not move that box’s baseline.

Compare sub/sup and font glyphs

Reference · native sub and sup

H2O · x2

Native request · verify the font glyphs

H2O · x2

The first row keeps native sub/sup. The second uses system-ui and resets sizing and alignment when position is accepted, avoiding two reductions. @supports keeps the first technique when syntax is missing, but cannot detect glyphs: when they are missing and not synthesized, the second row can lose its visual positioning.
Compare sub/sup and font glyphs
<div class="font-variant-guide-position">
  <div>
    <p class="label">Reference · native sub and sup</p>
    <p class="sample">H<sub>2</sub>O · x<sup>2</sup></p>
  </div>
  <div>
    <p class="label">Native request · verify the font glyphs</p>
    <p class="sample enhanced">H<sub>2</sub>O · x<sup>2</sup></p>
  </div>
</div>
.font-variant-guide-position {
  display: grid;
  gap: 1rem;
  font-family: Georgia, serif;
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;

  .label {
    margin-block: 0 0.5rem;
    font-size: 1rem;
    font-variant: normal;
  }

  .sample {
    margin: 0;
  }

  .sample {
    font-family: system-ui, sans-serif;
  }

  @supports (font-variant-position: super) and (font-variant-position: sub) {
    .enhanced sub,
    .enhanced sup {
      font-size: inherit;
      vertical-align: baseline;
    }

    .enhanced sub {
      font-variant-position: sub;
    }

    .enhanced sup {
      font-variant-position: super;
    }
  }
}

The specification requires synthesis of the whole run when positional glyphs are missing, but BCD records missing synthesis in Chrome and Safari for sub/super. Before using the example’s reset in production, verify the effective font and every character; if you cannot guarantee them, keep the first row’s native presentation.

This scene compares real requests; system-ui does not guarantee these glyphs on every device either. Position is inherited: apply it only to the appropriate fragment. Keep sub/sup and their meaning; @supports alone cannot determine whether removing native sizing and alignment is safe.

Common mistakes

A variant makes no visible difference

Expected result
See an available typographic feature.
Cause
Alternate glyphs are missing or another font is rendering those characters.
Solution
Check the rendered font, its features and the language. Test relevant characters and keep a readable presentation when there is no difference.

Adding ligatures clears tabular figures

Expected result
Keep the previous variants.
Cause
A new font-variant declaration has reset the omitted components.
Solution
Change font-variant-ligatures or write the full set. Also check later font shorthands and cascade order.

The property says tabular, but digits remain proportional

Expected result
Apply the requested spacing.
Cause
Besides possible font limitations, font-feature-settings can impose conflicting low-level features.
Solution
Prefer font-variant-* for these features. Inspect and remove overrides such as "tnum" 0 before attributing the result to the browser.

Support and compatibility

MDN lists font-variant and the five subproperties covered here as Baseline Widely Available, with partial limitations in position: BCD records sub/super without synthesis of missing glyphs in Chrome and Safari. Check values, combinations and the font; the overall label does not guarantee each result.

The six scenes use native HTML/CSS and local or generic fonts; they do not download a font guaranteeing every variant. @supports checks syntax, getComputedStyle reports computed values and font tools help identify the actual resource. Also review reading, fallback and text enlarged to 200%.