innerHTML. The getter serialises the element's children as HTML. The setter runs the HTML fragment parser with the element as context and replaces all children with the result. Two consequences:
<script>elements it creates never execute: the fragment is parsed in an inert scripting mode.- Everything else is live markup.
<img src=x onerror=…>runs its handler when the image fails, so assigning untrusted strings is an XSS hole.
textContent. Defined by the DOM Standard on every node. On an element it returns the concatenated data of all descendant Text nodes in tree order: including text in <script>, <style>, and elements hidden by CSS or hidden. On document it's null. The setter replaces all children with one Text node (none for ""), so markup is never parsed. It's the safe, cheap way to write text.
innerText. Defined by the HTML Standard on HTMLElement, it returns the text as rendered: elements with display: none or non-visible visibility are skipped, text-transform is applied, and block boundaries and <br> become line breaks. That needs up-to-date styles and layout, so reading it after DOM changes forces a synchronous layout. If the element itself isn't rendered, it falls back to textContent-style output. The setter turns \n into <br>.
setHTML(html, { sanitizer }). Parses like innerHTML, then sanitises before inserting. With no sanitizer it uses the built-in safe default, which keeps only elements categorised Default (<b>, <p>… but not <img>), and drops comments, data-* attributes and javascript: URLs. With a custom config it still removes everything unsafe, such as <script> and on* handlers, whatever the config allows. setHTMLUnsafe() is the unsanitised counterpart that, unlike innerHTML, parses declarative shadow roots. The Sanitizer API moved from its WICG draft into the HTML Standard; setHTML() shipped in Chrome 146 and Firefox 148, not in Safari.