title: Is it ok to write almost any unescaped text inside textarea and get it from JS with it's value property?
body: <p>I've noticed that inside HTML textarea element I can set almost any default value without escaping and access it from JavaScript through that element node's <code>value</code> property like below:
  HTML:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;textarea id=&quot;txt&quot;&gt;
    &lt;h1&gt;A h1 heading&lt;/h2&gt;
    &lt;!-- this is comment --&gt;
    &lt;textarea&gt;This is a textarea&amp;lt;/textarea&gt;
  &lt;/textarea&gt;
  </code></pre>
  <p>JS:</p>
  <pre class="lang-js prettyprint-override"><code>console.log(txt.value)
  </code></pre>
  <p>JS Output:</p>
  <pre><code>  &lt;h1&gt;A h1 heading&lt;/h2&gt;
    &lt;!-- this is comment --&gt;
    &lt;textarea&gt;This is a textarea&lt;/textarea&gt;
  </code></pre>
  <p>To print the nested textarea tag I only needed to escape that <code>&lt;</code>. If escape all the angle brackets then it also works. But that is too much work.</p>
  <p>My question is it the standard behavior? I've found no articles or docs saying about. I looked into <a href="https://html.spec.whatwg.org/" rel="nofollow noreferrer">spec</a>. But it seemed too complex. Is it safe to build app assuming it will work like this on all browsers? Can you please give reference to part of the spec that explains this?</p>