From the course: Learning Web Components

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Declare template content

Declare template content

From the course: Learning Web Components

Start my 1-month free trial

Declare template content

- [Instructor] Let's take what we've learned about the template tag so far and put it to use in an example. To use the template tag, you simply write the tag within your markup. And again it could be placed in either the head or the body, anywhere where the parser allows content model with child notes. Inside the template, you place whatever content you want it to hold. Template content can be regular markup such as text or images or other elements. It can also be active content such as JavaScript. Now remember that templates are inert until they are activated. So in this case, the image won't actually be fetched by the browser until the template is instantiated and inserted into the document. Similarly, the script code won't be executed by the browser when the template is first parsed. Okay, let's see how this looks in real code and switch over to our editor. I'm here in Adobe Brackets and I have opened the exercise files folder in my editor and if you're using Brackets you can do…

Contents