docs.rodeo

MDN Web Docs mirror

Element: getHTML() method

{{APIRef("DOM")}} 

The getHTML() method of the {{domxref("Element")}}  interface is used to serialize an element’s DOM to an HTML string.

The method provides an options argument that enables the serialization of child nodes that are shadow roots. The options can be used to include nested shadow roots that have been set as {{domxref("ShadowRoot/serializable","serializable")}} , and/or a specified array of {{domxref("ShadowRoot")}}  objects, which may be either open or closed.

Without arguments, child nodes that are shadow roots are not serialized, and this method behaves in the same way as reading the value of {{domxref("Element.innerHTML")}} .

Syntax

getHTML(options)

Parameters

Return value

A string that represents the HTML serialization of the element.

Exceptions

None.

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See Also

In this article

View on MDN