Students name a place on a page with id and link to it with href="#name", so a menu can jump to each part of a long page.
Load these into Waypoints Prepare: choose Load URL and paste the copied address, or download the file and import it. In Prepare, the worksheet's Teacher edition shows the answers; the student copy hides them.
Predict and Run 10 min · Investigate 8 min · Modify 8 min · Mix it up 4 min · Make 12 min
Do the Make task yourself (about 5 minutes).
An id is an attribute that gives one element a name. A link whose href starts with # goes to the element with that name on the same page. The # is the whole difference between "this page" and "another page". Pages need to be long enough to scroll, or the jump is invisible: make the preview small or add a paragraph.
On the slides at these points. Students can do the whole lesson on their own; these are for the room. In the deck, the Run, Modify and Make slides have the live playground in them (the tutorial link is the backup), and the notes above are in each slide's speaker notes.
Look at the code. Point to where you think the page will scroll when someone clicks Results, and tell your partner how you know.
Listen for students who point at the link itself. Ask them what in the heading tells the browser this is the place.
Swap pages with a partner. Click every link in their menu. Tell them which link does nothing, and read the name in the link and in the heading aloud.
Most failures are a missing #, a different spelling, or a capital letter. Let the partner find the mismatch.
Matching the name in the href and the id exactly, and remembering the # in the href only. Have them click every link to test it.
| What you will see | A question to ask | The fix |
|---|---|---|
| Clicking a menu link does nothing. | Is the name in the href exactly the name in the id, with a | Make the two names match letter for letter. Only the href has the |
| Clicking a menu link tries to open another page. | Does the href start with | Put a |
| The id has a | Where does the | The |
<header>
<h1>Chess club</h1>
<nav>
<ul>
<li><a href="https://example.com/rules">Rules</a></li>
<li><a href="https://example.com/join">Join</a></li>
</ul>
</nav>
</header>
One possible solution for each task. Other correct programs are fine.
<header>
<h1>Chess club</h1>
<nav>
<ul>
<li><a href="#results">Results</a></li>
<li><a href="#join">Join</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2 id="meet">When we meet</h2>
<p>Wednesdays at lunch in room 4. Bring a board if you have one.</p>
</section>
<section>
<h2 id="results">Results</h2>
<p>The Owls won the autumn ladder. The Hawks came second.</p>
</section>
<section>
<h2 id="join">Join</h2>
<p>Come to room 4 on Wednesday and ask for a game.</p>
</section>
</main>
<header>
<h1>Chess club</h1>
<nav>
<ul>
<li><a href="#meet">When we meet</a></li>
<li><a href="#results">Results</a></li>
<li><a href="#join">Join</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2 id="meet">When we meet</h2>
<p>Wednesdays at lunch in room 4. Bring a board if you have one.</p>
</section>
<section>
<h2 id="results">Results</h2>
<p>The Owls won the autumn ladder. The Hawks came second.</p>
</section>
<section>
<h2 id="join">Join</h2>
<p>Come to room 4 on Wednesday and ask for a game.</p>
</section>
</main>
<header>
<h1 id="top">Chess club</h1>
<nav>
<ul>
<li><a href="#meet">When we meet</a></li>
<li><a href="#results">Results</a></li>
<li><a href="#join">Join</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2 id="meet">When we meet</h2>
<p>Wednesdays at lunch in room 4. Bring a board if you have one.</p>
</section>
<section>
<h2 id="results">Results</h2>
<p>The Owls won the autumn ladder. The Hawks came second.</p>
</section>
<section>
<h2 id="join">Join</h2>
<p>Come to room 4 on Wednesday and ask for a game.</p>
</section>
</main>
<p><a href="#top">Back to the top</a></p>
<header>
<h1>Chess club</h1>
<nav>
<ul>
<li><a href="#rules">Rules</a></li>
<li><a href="#results">Results</a></li>
<li><a href="#join">Join</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2 id="rules">Rules</h2>
<p>Think before you move. Shake hands at the end.</p>
</section>
<section>
<h2 id="results">Results</h2>
<p>The Owls won the autumn ladder.</p>
</section>
<section>
<h2 id="join">Join</h2>
<p>Come to room 4 on Wednesday.</p>
</section>
</main>
Stretch: Add a fourth part with its own id and menu link, and a link at the bottom of the page that jumps back to the top (give the heading an id).
Support: Give students the Make starter with the ids already added, and ask them only to build the nav and the links.
A menu link has href="results" and a heading has id="results". The link does not jump. What is missing, and why?
The #. href="#results" means the element named results on this page; without it the browser looks for another page called results.
Next lesson uses id again: a form label points at its box by id, so clicking the label finds the box. Class idea: find a long page (a Wikipedia article) and look at how its contents list jumps down the page.