# Cloning Nodes

There is a method that lets you clone HTML Nodes so that you can add additional copies elsewhere on your page.

let element = document.querySelector("main > p");
//get a reference to the first paragraph inside the main element.
element.cloneNode(true); //making a copy of a Node so it can be added elsewhere
1
2
3

The true or false value passed to the method tells it if the copy is deep or not. In other words, whether you want just the node OR the node and all of the content and children inside of it.

# HTML Template Elements

In HTML, there is an element called <template> which will let you add some sample HTML that you will be using in the future, possibly multiple times, as you add new content to the page.

Back to Week 6 main page

Last Updated: 6/13/2020, 11:30:19 PM