cssnumber-formatting

Formatting numbers (decimal places, thousands separators, localization, etc) with CSS


Is it possible to format numbers with CSS? That is: decimal places, decimal separator, thousands separator, etc.


Solution

  • Unfortunately, it's not possible with CSS currently, but you can use Number.prototype.toLocaleString(). It can also format for other number formats, e.g. latin, arabic, etc.

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString