Aligning decimal points in HTML

后端 未结 11 1764
渐次进展
渐次进展 2020-11-27 12:52

I have a table containing decimal numbers in one column. I\'m looking to align them in a manner similar to a word processor\'s \"decimal tab\" feature, so that all the poin

11条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 13:26

    I'm surprised that in 10 years of answers to this question, nobody ever mentioned the Unicode character 'FIGURE SPACE' (U+2007, )

    It's a whitespace character that is designed (by font authors, if they follow the standard) to be the same width as digits and to keep its spacing, like its more famous cousin the No-Break Space. You can use it to pad numbers to a certain string size, either on the left or on the right hand side, taking care of aligning the column or div on the same side.

    Examples, both left-aligned and left-padded with figure spaces:

    10000
      123.4
        3.141592

    10000
      123.4
        3.141592

提交回复
热议问题