HTMLTemplateElement
Web Components
Web Components
The HTMLTemplateElement interface enables access to the contents of an HTML template element.
[!NOTE] An HTML parser can create either an
HTMLTemplateElementor a ShadowRoot when it parses a template element, depending on the<template>attributes. If anHTMLTemplateElementis created the "shadow" attributes are reflected from the template. However these are not useful, because anHTMLTemplateElementis not a shadow root and cannot subsequently be changed to a shadow root.
Instance properties
This interface inherits the properties of HTMLElement.
- content
- : A read-only DocumentFragment which contains the DOM subtree representing the template element's template contents.
- htmlFor
- : A string reflecting the
forHTML attribute, containing the ID of the Processing Instruction marker to replace with the contents of this<template>element. - shadowRootMode
- : A string that reflects the value of the
shadowrootmodeattribute of the associated<template>element. - shadowRootDelegatesFocus
- : A boolean that reflects the value of the
shadowrootdelegatesfocusattribute of the associated<template>element. - shadowRootClonable
- : A boolean that reflects the value of the
shadowrootclonableattribute of the associated<template>element. - shadowRootCustomElementRegistry
- : A string that reflects the value of the
shadowrootcustomelementregistryattribute of the associated<template>element, indicating that the declarative shadow root will use a scoped CustomElementRegistry. - shadowRootSerializable
- : A boolean that reflects the value of the
shadowrootserializableattribute of the associated<template>element. - shadowRootSlotAssignment
- : A string that reflects the value of the
shadowrootslotassignmentattribute of the associated<template>element.
Instance methods
This interface inherits the methods of HTMLElement.