Newly available Newly available. Verify your target environments before adopting.

Browser support

Feature Desktop Mobile
Chrome
Edge
Firefox
Safari
Chrome Android
Safari iOS
125
125
128
18
125
18

The getHTML() method of the ShadowRoot interface is used to serialize a shadow root's DOM to an HTML string.

125
125
128
18
125
18
1+Supported (version) Not supported Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)

Syntax

JAVASCRIPT
getHTML(options)

Use cases

  • Using getHTML()

    The getHTML() method of the Element interface is used to serialize an element's DOM to an HTML string.

Cautions

  • May not be supported in older browsers.

Implementation notes

  • Some APIs require a secure context (HTTPS) or user activation. Check the requirements before use.