← Teacher guide

Attributes and links

Students find out that a link is words plus an address in an href attribute, and that only the words show on the page.

Structure and style a page · Lists, links and pictures · about 40 minutes · Open the student lesson

Classroom resources

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.

Students will be able to

Timing

Predict and Run 10 min · Investigate 8 min · Modify 8 min · Mix it up 4 min · Make 10 min

Before class

Read the unit primer "Lists, links and pictures in 5 minutes" first, then do the Make task yourself in the playground (about 5 minutes).

An attribute is extra information about a tag, written inside the opening tag as name="value". href is the attribute that holds a link's address. The surprise for students is that the address does not show: only the words between <a> and </a> do. Links to example.com open a real placeholder page, so students can test a click.

Running the lesson

  1. Predict and Run: many students pick the option where the address shows. Let them run it and click, then use Modify to change only the address and only the words, so they see the two parts are separate.
  2. Investigate: the question is about where the attribute goes. In the bug, read line 4 aloud: the text after the > is just text.
  3. Modify: three small changes: the address only, the words only, then a new link. Ask which part of the tag each change touched.
  4. Mix it up: the list bug is from last lesson. Ask what closed the list before the third item.
  5. Make: the check ticks when the page has a list with a link in it; look at the page to see that two items are links.

In class

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.

The hard part (on purpose)

Putting the attribute in the right place. Ask which part of the tag is the opening one, rather than fixing the line.

When students get stuck

What you will seeA question to askThe fix
The address shows on the page next to the words.Is the href inside the opening tag, before the first >?Move href="..." between a and the first >, so the tag reads <a href="...">.
The words are not a different colour and nothing clicks.Does the link have both its <a href="..."> and its </a>?Add the missing opening tag with href, or the closing </a>, around the words.
Everything after the link is clickable.Where does the link end?Add </a> straight after the words that should click.

Answers to the checks

  1. Predict: What will the page show, and what happens when someone clicks?
    Read the club rules before you join. Only the words between <a> and </a> show, as a link. The address stays inside the tag and the click takes you there.
  2. Which tag?: Which opening tag makes a link to https://example.com/join?
    <a href="https://example.com/join">
    The attribute is called href, so it is written href="address" after the a and a space, inside the opening tag. Other names, or a missing name, mean the browser does not know where to go.
  3. The link that does not click: The page shows Timetable href=... as plain text next to a word that does not click, while the other two links work. Click the line that causes it.
    line 4
    On line 4 the href is after the > and so counts as text on the page. An attribute goes inside the opening tag: <a href="https://example.com/timetable">Timetable</a>.
  4. Mix it up: Art should be the third club in the list, but it shows without a bullet and further left. Click the line that causes it.
    line 6
    Line 6 is outside the list: </ul> on line 5 already closed it. Every <li> must be inside the <ul>, links or not.

Solutions

One possible solution for each task. Other correct programs are fine.

Modify › Change the address

<h1>Sports day</h1>
<p>Read the <a href="https://example.com/join">club rules</a> before you join.</p>
<p>Ask your house captain for the timetable.</p>

Modify › Change the words

<h1>Sports day</h1>
<p>Read the <a href="https://example.com/join">rulebook</a> before you join.</p>
<p>Ask your house captain for the timetable.</p>

Modify › Add a link

<h1>Sports day</h1>
<p>Read the <a href="https://example.com/join">rulebook</a> before you join.</p>
<p>Ask your house captain for the <a href="https://example.com/timetable">timetable</a>.</p>

Make

<h1>My top 5 books</h1>
<ol>
  <li><a href="https://example.com/hobbit">The Hobbit</a></li>
  <li>Wonder</li>
  <li><a href="https://example.com/holes">Holes</a></li>
  <li>Matilda</li>
  <li>Hatchet</li>
</ol>

Stretch and support

Stretch: Make a link to one of your own other pages in the playground, or a whole sentence into a link, and test where it ends.

Support: Give students the Modify starter and do the first task together, then link one item in the Make list.

Exit ticket

In <a href="https://example.com/rules">club rules</a>, which part do people see on the page, and which part says where the link goes?

They see club rules. The href attribute, inside the opening tag, says where it goes.

What each step is for

Where it leads

Next lesson adds pictures, which are another tag with attributes: a name for the file and words for people who cannot see it. Class idea: show a real school page and hover over links to see the address in the browser's status bar.