Concepts

Plain-text DOM sink

Try the free JavaScript compiler

Assign plain text without HTML parsing. Choose the element and its context in trusted code.

Formal Syntax & Structure

javascript syntaxjavascript
element.textContent = text

Working Example

Example Snippetjavascript
(async () => {const el=document.createElement("p");el.textContent="<b>Notebook</b>";console.log(el.textContent,el.children.length);})()
JavaScript Reference