Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Typography

The font-variant-numeric property

Reference for the CSS font-variant-numeric property: tabular-nums, lining-nums, oldstyle-nums, slashed-zero, ordinal and fractions, with live examples.

The font-variant-numeric property picks alternative forms for digits, fractions and ordinal markers. The most useful value is tabular-nums, which gives every digit the same width so numbers line up in columns and counters do not jiggle as they change.

Fonts differ in their defaults. Some use proportional lining figures, others use old-style figures that sit like lowercase letters. This property lets you ask for a specific style, as long as the font includes it.

CSS
td.amount {
  font-variant-numeric: tabular-nums slashed-zero;
}

Try it

Numeral styles

The lines differ only where your font offers the variant. A font whose digits are already tabular and lining shows no change for those values.

Syntax

CSS
font-variant-numeric: normal
  | [ <numeric-figure-values> || <numeric-spacing-values>
    || <numeric-fraction-values> || ordinal || slashed-zero ];

/* <numeric-figure-values>   = lining-nums | oldstyle-nums */
/* <numeric-spacing-values>  = proportional-nums | tabular-nums */
/* <numeric-fraction-values> = diagonal-fractions | stacked-fractions */
Initial value normal
Applies to All elements and text
Inherited Yes
Animatable No
Computed value As specified

Values

Value Description
normal Uses the font's default numerals.
lining-nums Digits all sit on the baseline at capital height.
oldstyle-nums Digits with ascenders and descenders, blending into lowercase text.
proportional-nums Each digit gets its natural width.
tabular-nums Every digit has the same width.
diagonal-fractions Renders 1/2 as a small diagonal fraction.
stacked-fractions Renders 1/2 as a stacked fraction.
ordinal Uses the ordinal marker forms (such as the raised letters in 1st, 2nd).
slashed-zero Draws a slash through the zero to distinguish it from the letter O.

Usage notes

  • Prices, tables and timers. Use tabular-nums for money columns, clocks and live counters so digits do not shift width as they change.
  • Combining values. You can combine one value from each group, as in lining-nums tabular-nums slashed-zero.
  • Font support. Many web fonts have these features, but system fonts often do not. Check the font's feature list before depending on a value.
  • Relationship to OpenType. The values map to OpenType features such as tnum, lnum, onum and zero; use font-feature-settings only for features without a named value.
  • Shorthand reset. Setting font-variant afterwards resets this property.

Browser support

Supported in all current browsers; whether a value changes the text depends on the font.