Reverse text direction for HTML input
P粉217629009
2023-08-22 12:58:49
<p>For my website, I need Arabic language support. Part of this is to provide an input text box where as the user types new characters must be appended to the left and the text must be right aligned. </p>
<p>Set the CSS property to </p>
<pre class="brush:php;toolbar:false;">text-align:right</pre>
<p> didn't work because I couldn't move the cursor to the left and add letters there. So I removed that attribute and added </p>
<pre class="brush:php;toolbar:false;">direction:RTL</pre>
<p>Here, the cursor is moved to the left and the text is right-aligned. But the newly added characters are not appended to the left side, but only to the end of the right side. </p>
<p>How do I fix this problem? Please help..</p>
<p>For example, check out the search box on Google’s Arabic page. I need the exact same behavior, albeit without those fancy keyboard icons etc, http://www.google.com/webhp?hl=ar</p>
You can use dir="rtl" on the input box. It is supported.
This is what I can think of:
direction:RTL
for right alignment