Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does <textarea> auto-encode inner html?

Tags:

html

textarea

I was trying to print some text between <textarea> and </textarea> tags, but I've noticed that if I input some characters like < and >, textarea automatically converts them to &lt; and &gt;.

Example:

<textarea><script></textarea>

will produce this HTML

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

Can you explain me why this happens?

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

like image 745
BeNdErR Avatar asked Nov 18 '11 16:11

BeNdErR


1 Answers

It doesn't escape the contents. The HTML source remains exactly the same. It just has the capability to display the contents as is which I guess is a requirement of the <textarea> tag.

like image 112
cherouvim Avatar answered Sep 19 '22 21:09

cherouvim