outerHTML
outerHTML is a property of the Element interface in the web platform. It returns the serialized HTML fragment that represents the element and all of its descendants, including the element's own start and end tags. By contrast, innerHTML returns only the HTML contained inside the element, excluding the element’s own tag.
Reading outerHTML yields a string containing the element’s complete markup. Setting outerHTML replaces the element in
Common uses include dynamic DOM updates, simple templating, and serializing a portion of the document for storage
Caveats and considerations include the re-parsing and re-insertion of HTML, which can affect performance and reset
See also: innerHTML, insertAdjacentHTML, replaceChild.
---