CSS font-variant-numeric Property
The font-variant-numeric property controls the appearance of numbers and related characters using numeric features available in a font.
It can select lining or oldstyle numerals, proportional or tabular spacing, diagonal or stacked fractions, ordinal forms, and slashed zeros. These features are particularly useful for tables, financial information, headings, and typography that requires consistent number formatting.
font-variant-numeric Syntax
The font-variant-numeric property accepts normal or a combination of compatible numeric feature keywords.
Basic Syntax
selector {
font-variant-numeric: normal;
}
Tabular Numerals
selector {
font-variant-numeric: tabular-nums;
}
Oldstyle Numerals
selector {
font-variant-numeric: oldstyle-nums;
}
Multiple Numeric Features
selector {
font-variant-numeric: lining-nums tabular-nums;
}
Fractions and Ordinals
.fractions {
font-variant-numeric: diagonal-fractions;
}
.ordinals {
font-variant-numeric: ordinal;
}
CSS-Wide Keywords
.example {
font-variant-numeric: inherit;
}
.example {
font-variant-numeric: initial;
}
.example {
font-variant-numeric: unset;
}
.example {
font-variant-numeric: revert;
}
.example {
font-variant-numeric: revert-layer;
}
Keywords from different numeric categories can be combined. Conflicting keywords within the same category cannot be used together.
Property Values
The following values control the available numeric typography features.
| Value | Description |
|---|---|
normal |
Uses the font's normal numeric presentation. |
lining-nums |
Uses numerals with a consistent height and alignment, generally similar to uppercase letters. |
oldstyle-nums |
Uses numerals with varying heights and possible ascenders or descenders. |
proportional-nums |
Uses numerals with widths that vary according to their shapes. |
tabular-nums |
Uses numerals with equal advance widths for consistent column alignment. |
diagonal-fractions |
Displays supported fractions with a diagonal fraction bar. |
stacked-fractions |
Displays supported fractions with the numerator above the denominator. |
ordinal |
Enables special glyph forms for ordinal indicators. |
slashed-zero |
Uses a zero glyph with a distinguishing slash when supported by the font. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | normal |
| Inherited | Yes |
| Applies to | All elements and text |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
These values request typographic features from the selected font. If the required glyphs or substitutions are unavailable, the browser may display the normal numeral forms.
How It Works
Many OpenType fonts contain alternative glyphs for numbers. The browser selects these glyphs according to the numeric features requested through CSS.
Default Numerals
.numbers {
font-variant-numeric: normal;
}
Equal-Width Numerals
.numbers {
font-variant-numeric: tabular-nums;
}
Oldstyle Numerals
.numbers {
font-variant-numeric: oldstyle-nums;
}
Combine Alignment and Style
.numbers {
font-variant-numeric: lining-nums tabular-nums;
}
Character Content
Numeric font variants change the displayed glyphs without changing the underlying digits. The text remains the same for copying, searching, and processing.
Important Consideration
The property does not format numeric values, insert separators, or perform calculations. It controls the appearance of characters already present in the document.
The normal Value
The normal value uses the font's default numeric presentation.
Basic Example
.numbers {
font-variant-numeric: normal;
}
HTML Example
<p class="numbers">0123456789</p>
Default Appearance
The font determines whether its default numerals are lining or oldstyle, proportional or tabular.
Reset a Custom Setting
.numeric-section {
font-variant-numeric: tabular-nums;
}
.numeric-section .regular-numbers {
font-variant-numeric: normal;
}
Important Consideration
The normal value does not guarantee a particular numeral style. Different fonts may use different default number designs.
Lining Numerals
The lining-nums value requests numerals with consistent vertical alignment, generally designed to match the height of uppercase letters.
Basic Example
.heading-numbers {
font-variant-numeric: lining-nums;
}
HTML Example
<h2 class="heading-numbers">Annual Report 2026</h2>
OpenType Feature
Lining numerals use the OpenType lnum feature.
Typical Uses
Lining numerals work well in headings, labels, charts, and interfaces where numbers should align visually with uppercase letters.
Lining vs. Tabular Numerals
Lining numerals control vertical appearance. They do not necessarily have equal widths. Use tabular-nums when consistent horizontal alignment is also required.
Important Consideration
Many fonts use lining numerals by default. In those fonts, explicitly setting lining-nums may produce no visible difference.
Oldstyle Numerals
The oldstyle-nums value requests numerals with varying heights, including forms that may extend above or below the normal lowercase letter height.
Basic Example
.article-numbers {
font-variant-numeric: oldstyle-nums;
}
HTML Example
<p class="article-numbers">The design was introduced in 1985.</p>
OpenType Feature
Oldstyle numerals use the OpenType onum feature.
Typical Uses
Oldstyle numerals are often used in books, articles, editorial layouts, and traditional typography where numbers should blend naturally with lowercase text.
Oldstyle vs. Lining Numerals
Lining numerals have a more uniform vertical appearance. Oldstyle numerals use varied heights and may include descenders.
Important Consideration
Oldstyle numerals require support from the selected font. Some fonts provide only lining numerals.
Proportional Numerals
The proportional-nums value requests numerals with widths that vary according to the shape of each digit.
Basic Example
.body-numbers {
font-variant-numeric: proportional-nums;
}
HTML Example
<p class="body-numbers">The values are 1111 and 8888.</p>
OpenType Feature
Proportional numerals use the OpenType pnum feature.
Typical Uses
Proportional numerals are useful in paragraphs, editorial content, and headings where natural character spacing is preferred.
Proportional vs. Tabular Numerals
Proportional numerals may occupy different widths. Tabular numerals use equal advance widths to support column alignment.
Important Consideration
Proportional numerals are not ideal when numbers must line up vertically across multiple rows.
Tabular Numerals
The tabular-nums value requests numerals with equal advance widths, making numeric columns easier to align.
Basic Example
.numeric-table {
font-variant-numeric: tabular-nums;
}
HTML Example
<table class="numeric-table">
<tr>
<td>Item A</td>
<td>125.00</td>
</tr>
<tr>
<td>Item B</td>
<td>888.50</td>
</tr>
</table>
OpenType Feature
Tabular numerals use the OpenType tnum feature.
Right-Aligned Numeric Columns
.numeric-table td:last-child {
text-align: right;
font-variant-numeric: tabular-nums;
}
Typical Uses
Tabular numerals are particularly useful in financial tables, statistics, dashboards, timers, and counters.
Changing Numbers
Equal-width digits can reduce distracting horizontal movement when displayed values change, such as in timers or live statistics.
Important Consideration
Tabular numerals provide equal widths for digits, but they do not automatically align decimal points or format entire table columns. Use appropriate table alignment and number formatting alongside this property.
Diagonal Fractions
The diagonal-fractions value requests fractions with smaller numerator and denominator glyphs separated by a diagonal fraction bar.
Basic Example
.fraction {
font-variant-numeric: diagonal-fractions;
}
HTML Example
<p class="fraction">1/2 + 3/4 = 5/4</p>
OpenType Feature
Diagonal fractions use the OpenType frac feature.
Typical Uses
Diagonal fractions are useful in recipes, measurements, product descriptions, and compact numeric text.
Fraction Formatting
The font may substitute supported digit and slash sequences with specially designed fraction glyphs.
Important Consideration
Not all fonts can form arbitrary fractions. Some support only a limited set of fraction substitutions.
This property changes the visual presentation of a fraction. It does not calculate or simplify its numeric value.
Stacked Fractions
The stacked-fractions value requests fractions with the numerator positioned above the denominator and separated by a horizontal bar.
Basic Example
.fraction {
font-variant-numeric: stacked-fractions;
}
HTML Example
<p class="fraction">1/2 + 3/4</p>
OpenType Feature
Stacked fractions use the OpenType afrc feature.
Typical Uses
Stacked fractions may be useful in specialized typography, mathematical notation, and layouts where horizontal fraction bars are preferred.
Font Availability
The afrc feature is less common than standard fraction support. Many fonts do not provide stacked fraction substitutions.
Important Consideration
For mathematical expressions requiring reliable fraction layout, use appropriate mathematical markup rather than depending on font substitutions alone.
Ordinal Forms
The ordinal value enables special glyph forms for ordinal indicators, such as the suffixes in 1st, 2nd, and 3rd.
Basic Example
.ordinal-text {
font-variant-numeric: ordinal;
}
HTML Example
<p class="ordinal-text">1st, 2nd, 3rd, and 4th</p>
OpenType Feature
Ordinal forms use the OpenType ordn feature.
Typical Appearance
Supporting fonts may replace ordinal suffixes with specially designed raised or reduced-size glyphs.
Typical Uses
Ordinal forms are useful for dates, rankings, numbered labels, and editorial typography.
Important Consideration
The ordinal value does not automatically generate ordinal suffixes. The suffix characters must already be present in the text.
Not every font provides ordinal substitutions for every language or character sequence.
Slashed Zero
The slashed-zero value requests a zero glyph containing a diagonal slash, helping distinguish the digit 0 from the letter O.
Basic Example
.code-number {
font-variant-numeric: slashed-zero;
}
HTML Example
<p class="code-number">O0 O0O0 100200</p>
OpenType Feature
Slashed zero uses the OpenType zero feature.
Typical Uses
Slashed zeros are useful for product identifiers, serial numbers, code samples, technical documents, and other text where confusing zero with the letter O could cause errors.
Combined with Tabular Numerals
.identifier {
font-variant-numeric: tabular-nums slashed-zero;
}
Important Consideration
Not every font includes a slashed zero glyph. Some fonts use a dotted zero or other distinguishing design instead, which is not necessarily controlled by this feature.
Combining Values
Compatible numeric feature keywords can be combined in one declaration.
Lining and Tabular Numerals
.financial-data {
font-variant-numeric: lining-nums tabular-nums;
}
Oldstyle and Proportional Numerals
.article-text {
font-variant-numeric: oldstyle-nums proportional-nums;
}
Tabular Numerals and Slashed Zero
.identifier {
font-variant-numeric: tabular-nums slashed-zero;
}
Lining Numerals with Ordinals
.ranking {
font-variant-numeric: lining-nums ordinal;
}
Invalid Numeral Style Combination
.numbers {
font-variant-numeric: lining-nums oldstyle-nums;
}
This declaration is invalid because the two values select conflicting numeral styles.
Invalid Spacing Combination
.numbers {
font-variant-numeric: proportional-nums tabular-nums;
}
This declaration is invalid because numerals cannot be requested as both proportional and tabular within the same declaration.
Invalid Fraction Combination
.fractions {
font-variant-numeric: diagonal-fractions stacked-fractions;
}
This declaration is invalid because the two fraction styles are mutually exclusive.
Invalid normal Combination
.numbers {
font-variant-numeric: normal tabular-nums;
}
The normal keyword must be used alone.
Font Support and OpenType Features
The available numeric variants depend on the OpenType features provided by the selected font.
OpenType Feature Mapping
| CSS Value | OpenType Feature |
|---|---|
lining-nums |
lnum |
oldstyle-nums |
onum |
proportional-nums |
pnum |
tabular-nums |
tnum |
diagonal-fractions |
frac |
stacked-fractions |
afrc |
ordinal |
ordn |
slashed-zero |
zero |
Professional Text Fonts
Many professional fonts provide multiple numeral styles, including lining, oldstyle, proportional, and tabular figures.
Interface Fonts
Some interface fonts include tabular numerals for counters, statistics, and other changing numeric content.
Custom Web Fonts
.report-data {
font-family: "Example Sans", Arial, sans-serif;
font-variant-numeric: lining-nums tabular-nums;
}
For predictable results, choose a font with documented support for the requested numeric features.
Fallback Fonts
If the preferred font is unavailable, the fallback font may provide different numeric styles or no optional numeric features.
Important Consideration
A browser may recognize every keyword while the selected font supports only some of the requested features.
The font-variant Shorthand
The font-variant shorthand can set numeric features alongside other font variants.
Longhand Example
.numbers {
font-variant-numeric: tabular-nums;
}
Shorthand Example
.numbers {
font-variant: tabular-nums;
}
Combining Numeric Features
.numbers {
font-variant: lining-nums tabular-nums;
}
Combining Numerals and Small Capitals
.heading {
font-variant: small-caps oldstyle-nums;
}
Shorthand Reset Behavior
.heading {
font-variant-numeric: tabular-nums;
font-variant: small-caps;
}
The later shorthand resets font-variant-numeric to normal because the numeric setting is not included.
Preserving Both Features
.heading {
font-variant: small-caps tabular-nums;
}
Important Consideration
Use font-variant-numeric when changing only numeric typography. Use the shorthand when several font variant categories need to be defined together.
Using font-feature-settings
The font-feature-settings property provides direct access to OpenType feature tags.
High-Level Tabular Numerals
.numbers {
font-variant-numeric: tabular-nums;
}
Low-Level Tabular Numerals
.numbers {
font-feature-settings: "tnum" 1;
}
High-Level Oldstyle Numerals
.numbers {
font-variant-numeric: oldstyle-nums;
}
Low-Level Oldstyle Numerals
.numbers {
font-feature-settings: "onum" 1;
}
High-Level Slashed Zero
.numbers {
font-variant-numeric: slashed-zero;
}
Low-Level Slashed Zero
.numbers {
font-feature-settings: "zero" 1;
}
Preferred Approach
Use font-variant-numeric for common numeric typography controls. Use font-feature-settings when direct control over OpenType tags is required.
Important Consideration
Low-level font feature settings can override corresponding high-level numeric variant controls. Avoid conflicting declarations unless the interaction is intentional.
Inheritance
The font-variant-numeric property is inherited. Child elements receive the parent's numeric typography settings unless they specify another value.
Inherited Numeric Settings
.report {
font-variant-numeric: tabular-nums;
}
<div class="report">
<p>Revenue: $12,500</p>
<p>Expenses: $8,250</p>
</div>
Override a Child Element
.report {
font-variant-numeric: tabular-nums;
}
.report .article-text {
font-variant-numeric: proportional-nums;
}
Explicit Inheritance
.child {
font-variant-numeric: inherit;
}
Reset to Initial Value
.child {
font-variant-numeric: initial;
}
Important Consideration
Inherited numeric settings may affect headings, paragraphs, table cells, and labels. Apply the property to appropriately scoped containers when different sections require different numeral styles.
font-variant-numeric Example
This example compares proportional and tabular numerals, then demonstrates numeric styling for a small financial table.
HTML Example
<div class="font-variant-numeric-demo">
<p class="demo-label">Proportional numerals</p>
<p class="proportional-numbers">111111 888888</p>
<p class="demo-label">Tabular numerals</p>
<p class="tabular-numbers">111111 888888</p>
<p class="demo-label">Financial table</p>
<table>
<thead>
<tr>
<th>Item</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Hosting</td>
<td>$125.00</td>
</tr>
<tr>
<td>Design</td>
<td>$1,850.00</td>
</tr>
<tr>
<td>Support</td>
<td>$85.50</td>
</tr>
</tbody>
</table>
</div>
CSS Example
.font-variant-numeric-demo {
font-family: Georgia, serif;
}
.font-variant-numeric-demo .demo-label {
margin: 0 0 8px;
font: 600 13px/1.4 Arial, sans-serif;
}
.font-variant-numeric-demo .proportional-numbers,
.font-variant-numeric-demo .tabular-numbers {
margin: 0 0 20px;
font-size: 28px;
}
.font-variant-numeric-demo .proportional-numbers {
font-variant-numeric: proportional-nums;
}
.font-variant-numeric-demo .tabular-numbers {
font-variant-numeric: tabular-nums;
}
.font-variant-numeric-demo table {
width: 100%;
border-collapse: collapse;
}
.font-variant-numeric-demo th,
.font-variant-numeric-demo td {
padding: 8px 12px;
border-bottom: 1px solid #ddd;
}
.font-variant-numeric-demo th:last-child,
.font-variant-numeric-demo td:last-child {
text-align: right;
font-variant-numeric: lining-nums tabular-nums;
}
Proportional numerals
111111 888888
Tabular numerals
111111 888888
Financial table
| Item | Amount |
|---|---|
| Hosting | $125.00 |
| Design | $1,850.00 |
| Support | $85.50 |
Proportional numerals may use different widths for digits such as 1 and 8. Tabular numerals request equal-width digits, making numeric columns easier to scan.
The financial table combines right alignment with lining and tabular numerals. The visual differences depend on whether the selected font supports these OpenType features.
Common Mistakes
The most common mistakes involve conflicting values, unsupported font features, and expecting the property to perform numeric formatting.
Combining Conflicting Numeral Styles
.numbers {
font-variant-numeric: lining-nums oldstyle-nums;
}
This declaration is invalid because the two values request different numeral styles.
Combining Conflicting Spacing Styles
.numbers {
font-variant-numeric: proportional-nums tabular-nums;
}
This declaration is invalid because the two values request conflicting numeral widths.
Combining Conflicting Fraction Styles
.numbers {
font-variant-numeric: diagonal-fractions stacked-fractions;
}
This declaration is invalid because only one fraction style can be requested.
Using normal with Other Values
.numbers {
font-variant-numeric: normal tabular-nums;
}
The normal keyword must be used alone.
Expecting Automatic Number Formatting
The property does not insert thousands separators, currency symbols, decimal points, or other formatting characters.
Expecting Automatic Fraction Calculations
Fraction features change glyph presentation but do not calculate mathematical values.
Expecting Every Font to Support Every Feature
Some fonts provide tabular numerals but not oldstyle figures, stacked fractions, or slashed zeros.
Ignoring Shorthand Reset Behavior
A later font-variant declaration can reset font-variant-numeric to normal.
Assuming Tabular Numerals Align Entire Columns
Equal-width digits help with alignment, but table layout, punctuation widths, and text alignment must still be handled separately.
Important Considerations
Keep the following points in mind when using the font-variant-numeric property:
- Purpose: Controls the appearance of numerals and related numeric glyphs.
- Property type: Longhand of
font-variant. - Initial value:
normal. - Inheritance: The property is inherited.
- Applies to: All elements and text.
- normal: Uses the font's default numeric presentation.
- lining-nums: Requests uniformly aligned lining numerals.
- oldstyle-nums: Requests numerals with varying heights.
- proportional-nums: Requests numerals with varying widths.
- tabular-nums: Requests equal-width numerals.
- diagonal-fractions: Requests diagonal fraction forms.
- stacked-fractions: Requests vertically arranged fractions.
- ordinal: Enables special ordinal indicator glyphs.
- slashed-zero: Requests a zero glyph with a distinguishing slash.
- Compatible combinations: Different numeric feature categories may be combined.
- Conflicting values: Mutually exclusive keywords cannot be combined.
- OpenType: The selected font must provide the requested features.
- Text content: Numeric variants do not change the underlying characters.
- Formatting: The property does not insert separators or calculate values.
- Tables: Combine tabular numerals with appropriate text alignment.
- Shorthand reset: A later
font-variantdeclaration may reset the property. - Browser support: Check compatibility and font feature availability.
Use font-variant-numeric to improve the consistency and readability of numbers. Tabular numerals are especially useful for financial data and counters, while oldstyle and proportional numerals can provide a more natural appearance in running text.
Browser Support
The CSS font-variant-numeric property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.
Individual numeric features depend on the browser's font shaping capabilities and the OpenType features included in the selected font.
Basic Example
.numbers {
font-variant-numeric: tabular-nums;
}
Feature Detection
@supports (font-variant-numeric: tabular-nums) {
.numbers {
font-variant-numeric: tabular-nums;
}
}
Progressive Enhancement
.numbers {
font-variant-numeric: normal;
}
@supports (font-variant-numeric: lining-nums tabular-nums) {
.numbers {
font-variant-numeric: lining-nums tabular-nums;
}
}
Font Feature Availability
The @supports rule checks whether the browser recognizes the CSS declaration. It does not confirm that the selected font includes the requested numeric glyphs.
For current compatibility information, visit Can I Use? and search for font-variant-numeric.
Specifications
The font-variant-numeric property is defined in the CSS Fonts Module, which describes numeric typography features and their relationships to OpenType font capabilities.
CSS Fonts Module Level 4: font-variant-numeric
The module also defines the font-variant shorthand and related typographic feature controls.
For additional explanations and examples, see MDN Web Docs.
