If I have a textarea
block like so...
<textarea name="myTextArea" cols="100" rows="20" readonly=readonly> .. text area content ... </textarea>
How can I embed HTML formatted text inside this text block? If I can I had figured the following should work...
<textarea name="myTextArea" cols="100" rows="20" readonly=readonly> <b>Hello how are you today?</b> </textarea>
As an example. But that sentence does not show up as bold. Maybe I'm just trying to do something that can't be done?
Render Content in a contenteditable DivAn HTML text area can't render HTML. However, we can make a div's content editable with the contenteditable attribute. Therefore. we can use an editable div as we do with a text area but with HTML content.
The HTML tag only accepts plain (unformatted) text. Even if you add HTML to it, or try to format it, it will be removed. What you need to do is use a Rich Text Editor. There are many you can use, for example CKEditor and TinyMCE.
You cannot place HTML elements inside a text area, only text content. only text content covers that part.
I am pretty sure the answer is no -- cannot do it with a textarea.
From the MDN docs:
The HTML <textarea> element represents a multi-line plain-text editing control.
- Permitted content Text
Is not possible with
<textarea>
Use this:
<div contenteditable="true"> </div>
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