Watch a countdown timer or a live CPU percentage on a web page and you’ll often see the text wiggle left and right every second. That’s because most fonts give each digit its own width: a 1 is narrower than an 8. One CSS line fixes it, and I’d put it on every number that changes or sits in a column.
.timer,
.price,
td.number {
font-variant-numeric: tabular-nums;
}
tabular-nums switches the font to figures that all have the same width (the OpenType tnum feature). A timer that goes from 1:11 to 8:48 keeps the same width, and prices in a table line up digit under digit, which is easier to compare at a glance. It’s the kind of detail you notice on a stats page like the ones Beszel or a home server dashboard show, where values update every few seconds.
The property takes more than one value, so you can combine features. slashed-zero puts a slash through the 0, which helps when people have to copy a code or a serial number where O and 0 look alike:
.serial {
font-variant-numeric: tabular-nums slashed-zero;
}
Other values you might like: oldstyle-nums for figures that drop below the line in running text, and diagonal-fractions to turn 1/2 into a proper fraction.
The caveat: CSS can only ask for these figures, the font has to have them. Most system fonts and popular web fonts ship tabular figures, but some display fonts don’t, and then nothing changes. If your font is one of those, a monospace font for the numbers is the fallback. Also keep it off normal body text: equal-width digits in a sentence look a bit spaced out.
Browser support is no worry: Chrome 52, Firefox 34 and Safari 9.1, and MDN marks it Baseline widely available since July 2022.
Further reading: MDN: font-variant-numeric