Browser & Web Performance · Junior · Question 60 of 75
Which way of putting user input into the page is safe from XSS?
- ✓Correct answer:
el.textContent = userInput - 2
el.innerHTML = userInput - 3
document.write(userInput)
Explanation
textContent treats the value as text, so <script> or <img onerror> are just characters, not markup.