diff --git a/files/en-us/web/api/element/gethtml/index.md b/files/en-us/web/api/element/gethtml/index.md new file mode 100644 index 000000000000000..379290e02832f2a --- /dev/null +++ b/files/en-us/web/api/element/gethtml/index.md @@ -0,0 +1,50 @@ +--- +title: "Element: getHTML() method" +short-title: getHTML() +slug: Web/API/Element/getHTML +page-type: web-api-instance-method +browser-compat: api.Element.getHTML +--- + +{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}} + +The **`getHTML()`** method of the {{domxref("Element")}} interface is used to serialize an element's DOM to an HTML string. + +## Syntax + +```js-nolint +const html = element.getHTML(options) +``` + +### Parameters + +- `options` {{optional_inline}} + + - : An options object with the following optional parameters: + + - `serializableShadowRoots` + - : A boolean value that specifies whether to include serializable shadow roots. The default value is `false`. + - `shadowRoots` + - : An array of {{domxref("ShadowRoot")}} objects to serialize. These are included regardless of whether they + are marked as serializable. The default value is an empty array. + +### Return value + +A string that represents the HTML serialization of the element. + +### Exceptions + +None. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See Also + +- {{domxref("ShadowRoot.getHTML()")}} +- {{domxref("Element.innerHTML")}} diff --git a/files/en-us/web/api/shadowroot/gethtml/index.md b/files/en-us/web/api/shadowroot/gethtml/index.md new file mode 100644 index 000000000000000..6e4978371ca2118 --- /dev/null +++ b/files/en-us/web/api/shadowroot/gethtml/index.md @@ -0,0 +1,49 @@ +--- +title: "ShadowRoot: getHTML() method" +short-title: getHTML() +slug: Web/API/ShadowRoot/getHTML +page-type: web-api-instance-method +browser-compat: api.ShadowRoot.getHTML +--- + +{{APIRef("DOM")}}{{SeeCompatTable}}{{SecureContext_Header}} + +The **`getHTML()`** method of the {{domxref("ShadowRoot")}} interface is used to serialize a shadow root's DOM to an HTML string. + +## Syntax + +```js-nolint +const html = shadowRoot.getHTML(options) +``` + +### Parameters + +- `options` {{optional_inline}} + + - : An options object with the following optional parameters: + + - `serializableShadowRoots` + - : A boolean value that specifies whether to include serializable shadow roots. The default value is `false`. + - `shadowRoots` + - : An array of {{domxref("ShadowRoot")}} objects to serialize. These are included regardless of whether they + are marked as serializable. The default value is an empty array. + +### Return value + +A string that represents the HTML serialization of the shadow root. + +### Exceptions + +None. + +## Specifications + +{{Specifications}} + +## Browser compatibility + +{{Compat}} + +## See Also + +- {{domxref("ShadowRoot.innerHTML")}}