ELEMENT.innerHTML = "FOO!" to replace the contents. ELEMENT.innerHTML += "FOO!" There must be an HTML element like paragraph, span, div etc. An HTML element must have an Id. We access the HTML element by using the id (to access an HTML element using Id, we use an HTML DOM method getElementbyId () ). Then, we write the text to the HTML element by using an HTML DOM property innerHTML. Example: 3 Answers. this is how I normally do it (simple and readable), unless there is an id in the markup. var html = '