Demo: innerHTML vs. textContent

With text "hard-coded" in the web page

This isn't something you would normally do. It's just to illustrate the difference between these two ways of putting text between HTML tags.

Some sample text with HTML mark-up:
This is some text that contains HTML tags and symbols—like mdash.

With user input

Type something in the Textarea below, click the Copy Text button, and it will be echoed back to the web page.