Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right justifying numbers in an input field

Tags:

html

Using this example, how would I right justify numbers in the input fields?

<html>
<body>

<form name="input" action="html_form_action.asp" method="get">
Taxes: <input type="number" name="Taxes" value="" /><br />
Shipping: <input type="number" name="shipping" value="" align="right" /><br />
<input type="submit" value="Submit" />
</form> 

<p>Click the "Submit" button, the form-data will be sent to a page called "html_form_action.asp".</p>

</body>
</html>
like image 562
Fred Rost Avatar asked Dec 18 '10 17:12

Fred Rost


People also ask

How do I align input tag in right?

We specify the margin-bottom of our <div> element. Then, we set the display of the <label> element to "inline-block" and give a fixed width. After that, set the text-align property to "right", and the labels will be aligned with the inputs on the right side.

How do you make an input field only accept numbers?

You can use the <input> tag with attribute type='number'. This input field allows only numerical values. You can also specify the minimum value and maximum value that should be accepted by this field.

How do I align text right in a text box?

Align text verticallyRight-click the text box for which you want to set vertical alignment. On the shortcut menu, click Format Text Box. In the Format Text Box dialog box, click the Text Box tab. In the Vertical alignment box, select Top, Middle, or Bottom.

How do I move input box to the right in HTML?

if you want to move everything to right, use css "float: right".


1 Answers

Style your input with:

text-align: right;

This will right justify all text in your input.

like image 191
alexn Avatar answered Oct 24 '22 11:10

alexn