Name

outerHTML — NN n/a IE 4 DOM n/a

Synopsis

Read/Write

The rendered text and HTML tags (i.e., all source code), including the start and end tags, of the current element. If you want only the rendered text, see outerText. For the source code that excludes the element’s tags, see innerHTML. A change to this property that includes HTML tags is rendered through the HTML parser, as if the new value were part of the original source code. You may change this property only after the document has fully loaded, and, in the process, you can even change the type of element it is or replace the element with straight text content. Changes to the outerHTML property are not reflected in the source code when you view the source in the browser. To add to existing HTML, see the insertAdjacentHTML( ) method. This property is not supported in many objects in the Macintosh version of Internet Explorer 4.

Example

document.all.elementID.outerHTML = 
    "<ACRONYM ID="quotes">NI<I>M</I>BY</ACRONYM>"

Value

String that may or may not include HTML tags.

Default

None.

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.