I am looking for the most elegant solution for putting both rtl and ltr languages together in a textarea: e.g. arabic and html together.
The standards say not to create it using css:
direction: rtl;
unicode-bidi: embed;
This does not work for me anyway, as the html has the nested text problem. Arabic is aligned to the right but the html is broken.
Is there a way to dynamically do this? The standard wants to add a nested span tag but since a user is dynamically typing this in I don't see how that's possible without detecting the end of each character.
Definition and Usage. The <textarea> tag defines a multi-line text input control. A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).
As you type more and more content, the textarea expands to include all of that text, rather than triggering a scrollbar as is the default. The plugin has a variety of options, but at its simplest you just load jQuery, the plugin file, and call it like this:
We can set the language in the HTML document by setting the lang attribute in the code. By default, the specified language is English, but it can be changed at our convenience. There is a way to change the content language by using Google for that, you can check this article, How To Add Google Translate Button On Your Webpage? ,
The <textarea> tag also supports the Global Attributes in HTML. The <textarea> tag also supports the Event Attributes in HTML. At w3schools.com you will learn how to make a website. They offer free tutorials in all web development technologies.
Since the content of a textarea
is taken as plain text, you cannot use any span
markup or any other markup there, and you cannot style any part of it as different from the rest of it (except the first line or the first character, using pseudo-elements).
However, at the plain text level, bidirectional embedding can be enforced using control characters. Assuming you set direction: rtl
on the element as a whole (expecting users to enter data in a right-to-left language), users can type U+202A LEFT-TO-RIGHT EMBEDDING to enter left-to-right text such as English or HTML markup and then end this, returning to right to left mode, by typing U+202C POP DIRECTIONAL FORMATTING.
Since most people do not know how to type these characters conveniently, if at all, you could have buttons for them on the page:
<textarea id=msg name=msg rows=10 cols=40>
</textarea>
<br>
<button type=button onclick="append('\u202A')">→</button>
<button type=button onclick="append('\u202C')">←</button>
<script>
var msg = document.getElementById('msg');
function append(ch) {
msg.innerHTML += ch;
msg.focus();
}
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With