Sometimes, we want to always show 2 decimal places with a HTML5 number input.
In this article, we’ll look at how to always show 2 decimal places with a HTML5 number input.
How to always show 2 decimal places with a HTML5 number input?
To always show 2 decimal places with a HTML5 number input, we use the step
attribute.
For instance, we write
<input type="number" step="0.01" value="0.00" placeholder="0.00" />
to set the step attribute to 0.01 to m,ake sure the HTML number input always show 2 decimal places.
Conclusion
To always show 2 decimal places with a HTML5 number input, we use the step
attribute.