If I have a textarea
block like so...
You are correct, it cannot be done.
According to MDN, "character data" is the only permitted content for a <textarea>
.
As other answers have described, what you are looking for is a WYSIWYG editor, like CKEditor, TinyMCE, or Kendo's Editor.
This is beside the point, but interestingly, MDN lists some examples on their HTMLTextAreaElement page on how to enable dynamic adding of HTML tags around text in a <textarea>
and how to enable autogrow behavior for a <textarea>
.
You can do this (convert the "special" characters):
<textarea name="myTextArea" cols="100" rows="20" readonly=readonly>
<b>Hello how are you today?</b>
</textarea>
You can try this too its simple and if you are using asp.net use lable contron in text area add this as
Text="< stonename >"
"<";stonename">";
You need to make a WYSIWYG Editor instead.
Here's a great one.
You can not do that inside textarea but what you can do...you can use p tag and parse information to tag by JQuery. Something like this:
var stringviewinfo ="aaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaa<b>aaaaaaaa</b>aaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaa<font color=\"red\">AAAA</font>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa<b>aaaaaaaaaaaaa<b>aaaaaaaaaaaaaaaaaaaaaaaaaaaa<br>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</br>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
$('#viewinfo').html(stringviewinfo);
<p style="word-wrap: break-word;" id="viewinfo"></p>
I hope this will help.
There is a very simple way you can achieve that.
First: Customize the <textarea>
to accept and save special chars to DB
<textarea contenteditable="true" class="form-control" name="setting[header_code]"><?php echo set_value('setting[header_code]', html_entity_decode($item->header_code)) ?></textarea>
Second: extract and echo the saved data from DB
<?php echo html_entity_decode(config(nl2br('header_code')));?>
Hope it can help you.
Thanks