How to Create a New DOM Element from HTML String
The <template> element is supported in all major browsers.
Note that HTML has restrictions on what element types you can use inside element types; for example, <td> cannot be put as a direct child of a <div> element. This causes the elements to vanish. The <template> element has no such restrictions on its content.
The <template> tag stores HTML code fragments that can be cloned and inserted in an HTML document. The <template> element is represented in DOM as a HTMLTemplateElement that has the .content property of DocumentFragment type so as to provide access to the contents of the template. This allows to convert an HTML string to DOM elements by setting the innerHTML of a <template> element, then reach into the .content property.