Does <textarea> autocoding internal html?

I tried to print text between the <textarea> and </textarea> tags, but I noticed that if I enter some characters, such as < and > , textarea will automatically convert them to &lt; and &gt; .

Example:

<textarea><script></textarea>

will create this HTML

<textarea>&lt;script&gt;</textarea>

Can you explain to me why this is happening?

Thanks in advance, any help is appreciated, best regards.

+6
source share
2 answers

This does not exclude content. The HTML source remains exactly the same. It just has the ability to display content, which I assume is a requirement of the <textarea> .

+4
source

The dom element must have the following properties:

 innerHTML = '&lt;script&gt;' innerText = '<script>' 
0
source

Source: https://habr.com/ru/post/901821/


All Articles