Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right align text in HTML input field

I have an HTML tag with a short maxlength but a long value attribute. I'd like the displayed text to show the end (right side) of the text, rather than the start (left side).

<input maxlength=10 value="A really really really long entry goes in here"/>

currently shows:

"A really r"

instead I'd like it to show:

"es in here"

Cheers,

Ian

like image 923
IanSR Avatar asked Feb 11 '11 19:02

IanSR


People also ask

How do I move text input to the right?

Add the text-align property set to “right” for the input.

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.

How do I center align text in a field in HTML?

If you only have one or a few blocks of text to center, add the style attribute to the element's opening tag and use the "text-align" property.


1 Answers

Do you want the visible area to start from the right? you can use css and the following rule input {direction:rtl;}

rtl means from right to left

example: http://jsbin.com/ilejo4

PS: the value of maxlength in your html must be wrapped with quotes, also you have to set the type of the input

like image 150
Sotiris Avatar answered Oct 01 '22 23:10

Sotiris