How can I align numeric input right and text input left with CSS?

The latest update for this can be done like below

  1. <input type="number" /> for Numbers Type of text fields.
  2. <input type="text"/> for text type of input fields

Then you can make use of CSS.

input[type=number] {
  text-align:right;
}


input[type=text] {
  text-align:left;
}

This would help you a lot if you add more fields to your webpage.


<style type="text/css">
     .right { text-align: right; } </style>

<input type="text" /> <input type="text" class="right"/>

Tags:

Css