Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Right to left Text HTML input

For my website, i need to provide arabic support. Part of it is to provide input textboxes where when user types in, the new characters have to be appended to the left and the text has to be right aligned.

setting the css property to

text-align:right 

didn't work, as i could not get the cursor to come to the left and add letters there. So I removed that property and added

direction:RTL 

Here, the cursor came to the left and text was right aligned. but the newly added characters were not getting appended to the left. Instead they were getting appended to the right end only.

How do I fix this? please help..

For example, see the google arabic page search box. I need the exact behavior, although not with those fancy keyboard icon etc., http://www.google.com/webhp?hl=ar

like image 540
Anand Avatar asked Sep 23 '11 05:09

Anand


People also ask

How do you make text go from right-to-left in HTML?

Setting up a right-to-left pageAdd dir="rtl" to the html tag any time the overall document direction is right-to-left (RTL). This sets the default base direction for the whole document. All block elements in the document will inherit this setting unless the direction is explicitly overridden.

How do you align text and input in HTML?

HTML | <input> align Attribute left: It sets the alignment of image to the left. it is a default value. right: It sets the alignment of image to the right. middle: It sets the alignment of image to the middle.


1 Answers

You can use the dir="rtl" on the input. It is supported.

<input dir="rtl" id="foo"/> 
like image 152
Nicholas Mayne Avatar answered Sep 24 '22 07:09

Nicholas Mayne