Most pages have the same big parts: a top area with the site name, a menu, the main content, and a bottom area with small print. HTML has a tag for each one:
<body>
<header>
<h1>Riverside Bakery</h1>
<nav>
<a href="/">Home</a>
<a href="/menu">Menu</a>
</nav>
</header>
<main>
<h2>Fresh every morning</h2>
<p>We bake from 5 am.</p>
</main>
<footer>
<p>Open daily, 7 am to 3 pm.</p>
</footer>
</body>
| Tag | What it is for |
|---|---|
<header> | The top of the page: logo, site name, menu |
<nav> | A group of links for getting around the site |
<main> | The content that is unique to this page. Use it once per page |
<section> | A part of the content with its own heading |
<footer> | The bottom of the page: contact details, copyright |
These are called semantic tags, because they describe meaning. They look no different in the browser. Their value is that search engines, screen readers and other developers can tell what each part of the page is. A person using a screen reader can jump straight to <main> and skip the menu.
Your Task
- Wrap the site name and the menu links in a
<header>. - Inside the header, wrap the two links in a
<nav>. - Wrap the heading and paragraph about the garden in
<main>. - Wrap the last paragraph in a
<footer>.
- The
<h1>is inside a<header> - Both links are inside a
<nav>that is inside the header - The
<h2>and the garden paragraph are inside<main> - The contact paragraph is inside a
<footer>, outside<main>
Lesson complete!
Next Lesson: Tables