CSS font-variant Property
The font-variant property is a shorthand that controls typographic features such as small capitals, ligatures, alternate letterforms, numeric styles, and East Asian text variants.
It provides a convenient way to apply several font variant settings in one declaration. The available effects depend on the selected font, its supported OpenType features, and browser compatibility.
font-variant Syntax
The font-variant property accepts the keywords normal and none, or a combination of supported font variant values.
Basic Syntax
selector {
font-variant: normal;
}
Small Capitals
selector {
font-variant: small-caps;
}
Numeric Variants
selector {
font-variant: tabular-nums lining-nums;
}
Multiple Features
selector {
font-variant: small-caps common-ligatures oldstyle-nums;
}
CSS-Wide Keywords
.example {
font-variant: inherit;
}
.example {
font-variant: initial;
}
.example {
font-variant: unset;
}
.example {
font-variant: revert;
}
.example {
font-variant: revert-layer;
}
When combining values, each keyword must belong to a compatible font variant category. The shorthand does not accept arbitrary combinations of conflicting values.
Property Values
The shorthand supports several groups of values that correspond to its longhand properties.
| Value or Group | Description |
|---|---|
normal |
Resets the font variant longhands to their initial values. |
none |
Disables the ligatures controlled by font-variant-ligatures and resets the other font variant longhands. |
small-caps |
Requests small-capital letterforms. |
all-small-caps |
Requests small capitals for both lowercase and uppercase letters. |
common-ligatures |
Enables common ligatures when supported by the font. |
no-common-ligatures |
Disables common ligatures. |
discretionary-ligatures |
Enables optional decorative ligatures. |
historical-ligatures |
Enables historical ligatures. |
lining-nums |
Requests numerals designed to align with uppercase letters. |
oldstyle-nums |
Requests numerals with varying heights and descenders. |
proportional-nums |
Requests numerals with varying character widths. |
tabular-nums |
Requests numerals with equal advance widths. |
ordinal |
Requests special glyphs for ordinal indicators. |
slashed-zero |
Requests a zero with a slash or similar distinguishing mark. |
sub, super |
Requests font-provided subscript or superscript glyphs. |
historical-forms |
Requests historical character forms. |
| East Asian keywords | Control regional glyph forms, character widths, and ruby text variants. |
Additional alternate glyph values, including stylistic(), styleset(), character-variant(), swash(), ornaments(), and annotation(), can be used when supported.
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | normal |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified for the constituent longhand properties |
| Animation type | As each longhand property |
| Percentages | Not applicable |
How It Works
The font-variant shorthand sets several font variant longhand properties at once. Each category controls a different aspect of the selected font's typographic features.
Selecting Font Features
.heading {
font-variant: small-caps;
}
This requests small-capital letterforms for lowercase letters.
Combining Features
.heading {
font-variant: small-caps discretionary-ligatures;
}
This requests small capitals and discretionary ligatures.
Using Font Features
Browsers map supported font variant settings to typographic features provided by the font, commonly through OpenType.
Missing Features
If the selected font does not contain a requested feature, the effect may be unavailable. Some capitalization and position variants may be synthesized when permitted by the browser.
Shorthand Reset Behavior
A font-variant declaration resets its constituent longhand properties, including those not explicitly represented by a keyword in the declaration.
Important Consideration
The property requests typographic features. It does not guarantee that the selected font contains the necessary glyphs.
The normal Value
The normal value resets the font variant longhands to their initial settings.
Basic Example
.paragraph {
font-variant: normal;
}
Resetting Small Capitals
.heading {
font-variant: small-caps;
}
.heading .regular-text {
font-variant: normal;
}
Default Behavior
The initial value of the shorthand is normal. This does not mean every optional font feature is disabled. For example, common ligatures may remain enabled through the normal behavior of the ligature longhand.
Important Consideration
Use normal to restore the default font variant settings rather than attempting to reverse individual features one at a time.
The none Value
The none value disables the ligatures controlled by font-variant-ligatures and resets the other constituent longhand properties to their initial values.
Basic Example
.code-label {
font-variant: none;
}
Disable Ligatures
.sample {
font-variant: none;
}
Difference Between normal and none
| Value | Behavior |
|---|---|
normal |
Restores the default settings, which may include common ligatures. |
none |
Disables the ligatures controlled by the ligature longhand and resets other variants. |
Important Consideration
The none value does not disable every possible OpenType feature or remove all font shaping behavior. It specifically controls the font variant features represented by the shorthand.
Small Capitals
Small capitals are uppercase-style letterforms designed to appear at approximately the height of lowercase letters.
Small Capitals
.heading {
font-variant: small-caps;
}
All Small Capitals
.heading {
font-variant: all-small-caps;
}
Petite Capitals
.heading {
font-variant: petite-caps;
}
All Petite Capitals
.heading {
font-variant: all-petite-caps;
}
Unicase
.heading {
font-variant: unicase;
}
Titling Capitals
.heading {
font-variant: titling-caps;
}
Small-Capital Synthesis
.heading {
font-variant: small-caps;
font-synthesis-small-caps: none;
}
This requests small capitals while preventing the browser from generating synthetic small-capital glyphs in browsers that support the synthesis control.
Important Consideration
Genuine small-capital glyphs generally provide better proportions than scaled uppercase letters. The available variants depend on the selected font.
Font Ligatures
Ligatures combine or modify character shapes to improve spacing, readability, or decorative appearance.
Common Ligatures
.paragraph {
font-variant: common-ligatures;
}
Common ligatures include combinations such as fi and fl when supported by the font.
Disable Common Ligatures
.paragraph {
font-variant: no-common-ligatures;
}
Discretionary Ligatures
.decorative-heading {
font-variant: discretionary-ligatures;
}
Historical Ligatures
.historical-text {
font-variant: historical-ligatures;
}
Contextual Alternates
.decorative-text {
font-variant: contextual;
}
Disable Contextual Alternates
.decorative-text {
font-variant: no-contextual;
}
Combining Ligature Settings
.heading {
font-variant: common-ligatures discretionary-ligatures;
}
Important Consideration
Ligature availability varies by font. Disabling ligatures may be useful for some technical displays, but it should not be applied universally without considering readability and text shaping.
Numeric Variants
Numeric variants control the appearance, width, and alignment of numerals.
Lining Numbers
.numbers {
font-variant: lining-nums;
}
Lining numbers generally align with uppercase letters.
Oldstyle Numbers
.numbers {
font-variant: oldstyle-nums;
}
Oldstyle numbers may contain varying heights and descenders, making them suitable for some body text designs.
Proportional Numbers
.numbers {
font-variant: proportional-nums;
}
Proportional numerals use widths appropriate to each character.
Tabular Numbers
.data-table {
font-variant: tabular-nums;
}
Tabular numerals have equal advance widths, helping digits align in tables and numerical displays.
Combining Numeric Features
.data-table {
font-variant: lining-nums tabular-nums;
}
Fractions
.fraction {
font-variant: diagonal-fractions;
}
.fraction {
font-variant: stacked-fractions;
}
Slashed Zero
.identifier {
font-variant: slashed-zero;
}
Ordinal Indicators
.ordinal {
font-variant: ordinal;
}
Important Consideration
Numeric variants are especially useful for financial tables, statistics, and other interfaces where consistent number alignment improves readability.
Alternate Glyphs
Alternate glyph features allow fonts to provide different letterforms for stylistic or historical purposes.
Historical Forms
.historical-text {
font-variant: historical-forms;
}
Stylistic Alternates
.decorative-text {
font-variant: stylistic(display);
}
Stylistic Sets
.decorative-text {
font-variant: styleset(alternate);
}
Character Variants
.decorative-text {
font-variant: character-variant(alternate);
}
Swash Characters
.decorative-heading {
font-variant: swash(decorative);
}
Ornaments
.decorative-text {
font-variant: ornaments(decorative);
}
Annotations
.annotation {
font-variant: annotation(circled);
}
Defining Named Alternates
Named alternate values are defined with the @font-feature-values rule for a particular font family.
@font-feature-values "Example Serif" {
@styleset {
alternate: 1;
}
}
.decorative-text {
font-family: "Example Serif", serif;
font-variant: styleset(alternate);
}
Important Consideration
The names used in these examples are illustrative. Named alternate features require matching @font-feature-values definitions and suitable glyphs in the selected font.
East Asian Variants
East Asian font variants provide controls for regional glyph forms, character widths, and ruby annotations.
Japanese Glyph Variants
.japanese-text {
font-variant: jis78;
}
.japanese-text {
font-variant: jis83;
}
.japanese-text {
font-variant: jis90;
}
.japanese-text {
font-variant: jis04;
}
Simplified and Traditional Forms
.simplified-text {
font-variant: simplified;
}
.traditional-text {
font-variant: traditional;
}
Full-Width Characters
.east-asian-text {
font-variant: full-width;
}
Proportional-Width Characters
.east-asian-text {
font-variant: proportional-width;
}
Ruby Text
rt {
font-variant: ruby;
}
Combining East Asian Features
.japanese-text {
font-variant: jis04 proportional-width;
}
Important Consideration
East Asian variants depend on font support and the writing system. Use appropriate language attributes and test the selected fonts with the actual text being displayed.
Superscripts and Subscripts
The font-variant shorthand can request font-provided superscript and subscript glyphs.
Superscript
.superscript {
font-variant: super;
}
Subscript
.subscript {
font-variant: sub;
}
Using Semantic HTML
<p>The area is measured in m<sup>2</sup>.</p>
<p>The chemical formula is H<sub>2</sub>O.</p>
Using Font Variants with HTML
sup {
font-variant: super;
}
sub {
font-variant: sub;
}
Font-provided position variants may be used when available. The HTML elements also have default browser styling, so combining these approaches requires care to avoid unintended sizing or positioning.
Important Consideration
Use <sup> and <sub> for meaningful superscripts and subscripts. Font variant styling alone does not provide their HTML semantics.
Combining Values
Several compatible font variant features can be combined in one declaration.
Small Capitals and Ligatures
.heading {
font-variant: small-caps common-ligatures;
}
Numeric Alignment
.statistics {
font-variant: lining-nums tabular-nums;
}
Small Capitals and Oldstyle Numbers
.editorial-heading {
font-variant: small-caps oldstyle-nums;
}
Multiple Ligature Controls
.decorative-text {
font-variant: common-ligatures discretionary-ligatures contextual;
}
Invalid Conflicting Values
.numbers {
font-variant: lining-nums oldstyle-nums;
}
This declaration is invalid because lining-nums and oldstyle-nums request conflicting numeric styles.
Another Invalid Combination
.heading {
font-variant: normal small-caps;
}
The normal keyword must be used alone.
Important Consideration
Combine values from compatible categories. When a declaration contains invalid combinations, the browser ignores the entire declaration.
Longhand Properties
The font-variant shorthand sets several specialized longhand properties.
| Longhand Property | Purpose |
|---|---|
font-variant-alternates |
Controls alternate glyph forms. |
font-variant-caps |
Controls capitalization variants. |
font-variant-east-asian |
Controls East Asian glyph variants. |
font-variant-emoji |
Controls emoji presentation preferences. |
font-variant-ligatures |
Controls ligatures and contextual alternates. |
font-variant-numeric |
Controls numeral styles and numeric features. |
font-variant-position |
Controls font-provided superscript and subscript glyphs. |
Shorthand Example
.heading {
font-variant: small-caps tabular-nums;
}
Equivalent Longhand Example
.heading {
font-variant-caps: small-caps;
font-variant-numeric: tabular-nums;
}
The longhand declarations express the two requested features without resetting unrelated font variant settings.
Shorthand Reset Behavior
.heading {
font-variant-numeric: tabular-nums;
font-variant: small-caps;
}
The later shorthand resets font-variant-numeric to its initial value because tabular-nums is not included.
Corrected Combination
.heading {
font-variant: small-caps tabular-nums;
}
Important Consideration
Use longhand properties when changing one feature without affecting the others. Use the shorthand when several font variant settings should be defined together.
Using font-feature-settings
The font-feature-settings property provides lower-level access to OpenType font features.
High-Level Font Variant
.heading {
font-variant: small-caps;
}
Low-Level OpenType Feature
.heading {
font-feature-settings: "smcp" 1;
}
Tabular Numbers
.statistics {
font-variant: tabular-nums;
}
.statistics {
font-feature-settings: "tnum" 1;
}
Discretionary Ligatures
.decorative-text {
font-variant: discretionary-ligatures;
}
.decorative-text {
font-feature-settings: "dlig" 1;
}
Preferred Approach
Use font-variant or its longhands for common typographic features. Use font-feature-settings when direct access to a specific OpenType feature is required.
Important Consideration
Low-level feature settings can interact with high-level font variant controls. Prefer the high-level properties when they provide the needed functionality.
Font Support and Fallbacks
The appearance of font variants depends on the selected font and its supported glyphs and OpenType features.
Font with Supported Features
.heading {
font-family: "Example Serif", Georgia, serif;
font-variant: small-caps;
}
If the selected font contains genuine small-capital glyphs, the browser can use them directly.
Font Without the Requested Feature
.statistics {
font-family: Arial, sans-serif;
font-variant: oldstyle-nums;
}
If the selected font lacks oldstyle numerals, the requested effect may not appear.
Fallback Fonts
Fallback fonts may provide different variant features. A feature available in one font may be unavailable in another.
Synthetic Small Capitals
.heading {
font-variant: small-caps;
font-synthesis-small-caps: auto;
}
Browsers may approximate missing small capitals when synthesis is permitted.
Custom Web Fonts
When using custom fonts, verify that the font files include the OpenType features required by the design.
Important Consideration
Test font variants using the actual fonts, characters, and languages used by the website. Browser support for a CSS value does not guarantee that the font contains the requested feature.
Inheritance
The font-variant property is inherited. Child elements receive the parent's font variant settings unless they specify their own values.
Inherited Setting
.article-heading {
font-variant: small-caps;
}
<div class="article-heading">
<h2>Typography <span>Reference</span></h2>
</div>
Override a Child Element
.article-heading {
font-variant: small-caps;
}
.article-heading .regular-text {
font-variant: normal;
}
Explicit Inheritance
.child {
font-variant: inherit;
}
Reset to Initial Values
.child {
font-variant: initial;
}
Important Consideration
Because the property is inherited, font variant settings applied to a container may affect headings, labels, links, and other descendant text.
font-variant Example
This example demonstrates several common font variant settings, including small capitals, numeric alignment, and ligatures.
The results depend on the selected font. Small capitals may be synthesized, while numeric variants and discretionary ligatures require suitable font features.
HTML Example
<div class="font-variant-demo">
<p class="demo-label">Normal text</p>
<p class="normal-text">Creative Typography</p>
<p class="demo-label">Small capitals</p>
<p class="small-caps-text">Creative Typography</p>
<p class="demo-label">Normal numerals</p>
<p class="normal-numbers">1234567890</p>
<p class="demo-label">Tabular numerals</p>
<p class="tabular-numbers">1234567890</p>
<p class="demo-label">Common ligatures</p>
<p class="ligature-text">office affinity efficient</p>
</div>
CSS Example
.font-variant-demo {
font-family: Georgia, serif;
}
.font-variant-demo p {
margin: 0 0 16px;
}
.font-variant-demo .demo-label {
font: 600 13px/1.4 Arial, sans-serif;
}
.font-variant-demo .normal-text,
.font-variant-demo .small-caps-text,
.font-variant-demo .normal-numbers,
.font-variant-demo .tabular-numbers,
.font-variant-demo .ligature-text {
font-size: 28px;
line-height: 1.4;
}
.normal-text {
font-variant: normal;
}
.small-caps-text {
font-variant: small-caps;
}
.normal-numbers {
font-variant: normal;
}
.tabular-numbers {
font-variant: tabular-nums;
}
.ligature-text {
font-variant: common-ligatures;
}
Normal text
Creative Typography
Small capitals
Creative Typography
Normal numerals
1234567890
Tabular numerals
1234567890
Common ligatures
office affinity efficient
The first two examples compare normal capitalization with small capitals. The numeric examples request default and tabular numeral forms.
The final example requests common ligatures. The appearance may be unchanged if the font already enables those ligatures by default or does not contain them.
Common Mistakes
The most common mistakes involve combining incompatible values or expecting features that the selected font does not provide.
Combining normal with Other Values
.heading {
font-variant: normal small-caps;
}
This declaration is invalid. The normal keyword must be used alone.
Combining none with Other Values
.heading {
font-variant: none common-ligatures;
}
This declaration is invalid. The none keyword must be used alone.
Using Conflicting Numeric Values
.numbers {
font-variant: proportional-nums tabular-nums;
}
These values request conflicting numeral widths and cannot be combined in the same declaration.
Using font-weight Values
.heading {
font-variant: bold;
}
This declaration is invalid. Use font-weight: bold to request bold text.
Using font-style Values
.heading {
font-variant: italic;
}
This declaration is invalid. Use font-style: italic to request italic text.
Expecting Every Font to Support Every Feature
Many fonts do not provide oldstyle numerals, discretionary ligatures, alternate glyphs, or genuine small capitals.
Overlooking Shorthand Resets
.heading {
font-variant-numeric: tabular-nums;
font-variant: small-caps;
}
The later shorthand resets the numeric variant. Include both values in the shorthand or use separate longhand declarations.
Confusing Font Variants with Text Transformation
The font-variant property controls glyph presentation. It does not replace text-transform for converting text to uppercase or lowercase.
Assuming All Features Have Identical Browser Support
Support varies among font variant categories. A browser may support small capitals while lacking support for newer or less common values.
Important Considerations
Keep the following points in mind when using the font-variant property:
- Purpose: Controls multiple typographic font variant features.
- Property type: Shorthand for the font variant longhand properties.
- Initial value:
normal. - Inheritance: Font variant settings are inherited.
- Applies to: All elements and text.
- normal: Restores the initial font variant settings.
- none: Disables the ligatures controlled by the ligature longhand and resets other variants.
- Small capitals: Use
small-capsor related capitalization values. - Ligatures: Common, discretionary, and historical ligatures may be controlled.
- Numeric variants: Lining, oldstyle, proportional, and tabular numerals are available when supported.
- Alternate glyphs: Stylistic sets and other alternates require matching font features.
- East Asian variants: Regional forms, widths, and ruby glyphs can be requested.
- Position variants: Font-provided superscript and subscript glyphs may be selected.
- Font support: The selected font must provide the relevant glyphs or features for many effects.
- OpenType: Many font variant values correspond to OpenType features.
- Shorthand reset: Unspecified constituent longhands are reset to their initial values.
- Longhands: Use individual font variant properties when only one category should change.
- Accessibility: Keep text readable and use semantic HTML for meaningful emphasis, importance, and superscripts or subscripts.
- Browser support: Check compatibility for specific features, especially newer values.
Use font-variant when several typographic features should be defined together. For more precise control, use the corresponding longhand properties.
Browser Support
The CSS font-variant property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari. Basic small-capital styling has been supported for many years.
Support for individual font variant features varies. Common ligatures, numeric variants, and capitalization features have broader support than some alternate glyph and newer emoji-related controls.
Basic Example
.heading {
font-variant: small-caps;
}
Feature Detection
@supports (font-variant: tabular-nums) {
.statistics {
font-variant: tabular-nums;
}
}
Progressive Enhancement
.heading {
font-variant: small-caps;
}
@supports (font-variant: small-caps discretionary-ligatures) {
.heading {
font-variant: small-caps discretionary-ligatures;
}
}
This example retains small capitals as a basic style and adds discretionary ligatures when the combined declaration is recognized.
Font Feature Availability
The @supports rule checks whether a CSS declaration is recognized. It does not verify that the selected font contains the requested OpenType features.
For current compatibility information, visit Can I Use? and search for font-variant or a specific font variant feature.
Specifications
The font-variant property is defined in the CSS Fonts Module, which describes font variant features, longhand properties, and font feature selection.
CSS Fonts Module Level 4: font-variant
The module also defines related properties for capitalization, ligatures, numeric variants, alternate glyphs, and East Asian text.
For additional explanations and examples, see MDN Web Docs.
