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

Is not possible with

<textarea> 

Use this:

<div contenteditable="true">
</div>

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>.


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

Tags:

Html