innerHTML

noun

say it: “IN-er AYCH-TEE-EM-EL” /ˈɪnər ˌeɪtʃ tiː ɛm ˈɛl/

An element's contents as an HTML string; setting it replaces them with new elements.

What is innerHTML in JavaScript?

innerHTML — An element's contents as an HTML string. Setting it replaces everything inside with new elements built from that HTML. Never put text a user typed into it: use textContent for that.

const list = document.getElementById("specials");
list.innerHTML = "<li>Chai</li><li>Chang</li>";

In a sentence

  • “I filled the specials list by setting its innerHTML to two li tags.”

Level: Apprentice · More JavaScript terms at this level

Updated