Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I embed HTML formatting inside of a <textarea> tag?

Tags:

html

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?

like image 888
Rob Segal Avatar asked Apr 05 '10 18:04

Rob Segal


People also ask

Can you render HTML inside textarea?

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.

How do I allow HTML tags in textarea?

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.

Can I put div inside textarea?

You cannot place HTML elements inside a text area, only text content. only text content covers that part.


2 Answers

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
like image 158
MJB Avatar answered Oct 08 '22 19:10

MJB


Is not possible with

<textarea>  

Use this:

<div contenteditable="true"> </div> 
like image 24
Sebastin Anthony Avatar answered Oct 08 '22 21:10

Sebastin Anthony