Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Is it ok to write almost any unescaped text inside textarea and get it from JS with it's value property?

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 value property like below: HTML:

<textarea id="txt">
  <h1>A h1 heading</h2>
  <!-- this is comment -->
  <textarea>This is a textarea&lt;/textarea>
</textarea>

JS:

console.log(txt.value)

JS Output:

  <h1>A h1 heading</h2>
  <!-- this is comment -->
  <textarea>This is a textarea</textarea>

To print the nested textarea tag I only needed to escape that <. If escape all the angle brackets then it also works. But that is too much work.

My question is it the standard behavior? I've found no articles or docs saying about. I looked into spec. 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?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!