Reputation: 40185
If I have two <input type="text" ...
and I know that one should accept text and the other a numeric value (and will check that in PHP when validating the form), can I align the contents of the text box left & the contents of the numeric box right using CSS?
Upvotes: 23
Views: 48053
Reputation: 555
The latest update for this can be done like below
<input type="number" />
for Numbers Type of text fields.<input type="text"/>
for text type of input fieldsThen 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.
Upvotes: 22
Reputation: 21
Just correction regarding CSS external file:
input.right{
text-align: right;
}
Upvotes: 0
Reputation: 648
<style type="text/css">
.right { text-align: right; } </style>
<input type="text" /> <input type="text" class="right"/>
Upvotes: 27