• Skip to main content
  • Skip to search
  • Skip to select language
    • Technologies Overview
    • HTML
    • CSS
    • JavaScript
    • Graphics
    • HTTP
    • APIs
    • Browser Extensions
    • MathML
    • Learn web development
    • Tutorials
    • References
    • Developer Guides
    • Accessibility
    • Game development
    • ...more docs
    • Send Feedback
    • Contribute to MDN
    • Report a content issue 🌐
    • Report a platform issue 🌐
  1. Web technology for developers
  2. Web APIs
  3. HTMLTemplateElement
  4. HTMLTemplateElement.content
  • Change language

Table of contents

  • Syntax
  • Example
  • Specifications
  • Browser compatibility
  • See also

HTMLTemplateElement.content

The HTMLTemplateElement.content property returns a <template> element's template contents (a DocumentFragment).

Syntax

var documentFragment = templateElement.content

Example

var templateElement = document.querySelector("#foo");
var documentFragment = templateElement.content.cloneNode(true);

Specifications

Specification
HTML Standard
# dom-template-content-dev

Browser compatibility

BCD tables only load in the browser

See also

  • HTMLTemplateElement

Found a problem with this page?

  • Edit on GitHub
  • Source on GitHub
  • Report a problem with this content on GitHub
  • Want to fix the problem yourself? See our Contribution guide.

Last modified: Sep 14, 2021, by MDN contributors

Change your language

Related Topics

  1. HTMLTemplateElement
  2. Properties
    1. content
  3. Inheritance:
    1. HTMLElement
    2. Element
    3. Node
    4. EventTarget
  4. Related pages for Web Components
    1. CustomElementRegistry
    2. Document.createElement()
    3. Element.attachShadow()
    4. Element.shadowRoot
    5. Element.slot
    6. Event.composed
    7. Event.composedPath
    8. HTMLSlotElement
    9. Node.getRootNode()
    10. Node.isConnected
    11. ShadowRoot
    12. Slotable
    13. Window.customElements
  • Web Technologies
  • Learn Web Development
  • About MDN
  • Feedback
  • About
  • MDN Web Docs Store
  • Contact Us
  • Firefox

MDN

  • MDN on Twitter
  • MDN on Github

Mozilla

  • Mozilla on Twitter
  • Mozilla on Instagram

© 2005-2022 Mozilla and individual contributors. Content is available under these licenses.

  • Terms
  • Privacy
  • Cookies