How to render HTML inside textarea?

Sometimes, we want to render HTML inside textarea.

In this article, we’ll look at how to render HTML inside textarea.

How to render HTML inside textarea?

To render HTML inside textarea, we replace it with a contenteditable div.

For instance, we write

<div contenteditable="true">
  This is the first line.<br />
  hello world
  <br /><span style="color: lightgreen">Great</span>.
</div>

to put some HTML inside the div.

We set its contenteditable attribute to true to make the div’s content editable.

Conclusion

To render HTML inside textarea, we replace it with a contenteditable div.