Purpose: This exercise is a continuation of Exercise 1.2, . Do Exercise 1.2 first.
This exercise assumes the sample webpage from Exercise 1.2 is still in your document root with the modifications you made in that exercise.
Before HTML5 in 2008, there was no simple way to put custom attributes in HTML tags. Only the pre-defined attributes were recognized, and Javascript would not see attributes other than those. The HTML5 standard allowed custom attributes so long as they begin with the prefix "data-" and are all lower-case. Practice using data-* attributes to automate your includes, then add a footer to include, as follows:
Add the following to index.js:
Now, in to index.html, about.html, and contact.html:
Replace this script:
with this one:
and change the nav element as follows:
It should work as before,
Create footer.html:
Now, add to index.html, about.html, and contact.html, on the bottom:
If done, right, this footer should now be included automatically when you load your page. Now you can add includes easily.
The next exercise uses it.