Align Numbers Perfectly with CSS tabular-nums

Comparison of misaligned proportional numbers and aligned tabular numbers using CSS font-variant-numeric.

Ever noticed how numbers often look misaligned?

That’s because most fonts use proportional numbers by default. Each digit takes up a different amount of space.

But there’s a fix for that.

In CSS, you can opt in to tabular numbers, where all digits have the same width. That makes columns of numbers line up perfectly.

Here’s how to enable it:

.after {
	font-variant-numeric: tabular-nums;
	font-feature-settings: 'tnum';
}

This works best with fonts that support OpenType features. But most system fonts and many web fonts do.

Clearer layouts, cleaner data tables, and a subtle polish your UI users will feel.

To learn more tips about CSS, make sure to join my newsletter below ❤️

    No strings attached, unsubscribe anytime!

    Other short articles you might like

    Explore more articles on front-end development, covering HTML, CSS and JavaScript for building high-performance websites.