Skip to content
Advertisement

How do I format numbers to add space on thousandth and none on ten thousandth etc

Let me show that in an example:

What it is:

$ 100,000
$ 10,000
$ 1,000

What I want:

$ 100,000
$  10,000
$   1,000

Also I wasn’t sure how to name the question. Any suggestions?

Advertisement

Answer

You can use something like in below snippet.

Define a width and text-align to the right

.rich {
  display: inline-block;
  width: 50px;
  text-align: right;
}
<span>$</span><span class="rich">100,000</span><br>
<span>$</span><span class="rich">1,000</span><br>
<span>$</span><span class="rich">100</span><br>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement