← Teacher guide

Pictures

Students show a picture with img, and learn that src must match the file name exactly and that alt describes the picture for people who cannot see it.

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 <img> tag has no closing tag, and the picture is a separate file. src names the file and alt describes it. The pictures students can use without uploading are trophy.svg, medal.svg, book.svg, ball.svg, star.svg and music.svg. Two ideas to land: a file name that is nearly right still fails, and alt is not a caption.

Running the lesson

  1. Predict and Run: many students pick the first option, that the close name still works. Let them run it and see the alt words. Fixing the name comes in Modify.
  2. Investigate: the first question is the one for alt-is-caption. Ask who actually reads alt. Then they apply it to the relay photo and the missing medal.
  3. Modify: three single changes: the file, the alt words, then the size. Misspell the name once on purpose and ask what shows.
  4. Mix it up: the picture inside a link needs the attribute lesson. Ask where the href goes.
  5. Make: the check ticks when the page has a heading, a picture with alt and a paragraph; read their alt words as a class.

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)

Believing that a nearly right file name will do. Let them see the alt words, then ask what the browser can compare the name to.

When students get stuck

What you will seeA question to askThe fix
The picture shows as words and a small broken icon.Is the file name in src spelt exactly like the file, with the same ending?Copy the file name from the list of pictures, including .svg.
The student typed alt words but sees none under the picture.When do people see alt?alt only shows when the picture cannot load, and screen readers read it. A caption would be a paragraph under the picture.
Words after the picture are inside the tag, or the picture vanishes.Does the img tag end with > and have no closing tag?End the tag with > straight after the last attribute and start the next element after it.

Answers to the checks

  1. Predict: The picture file is called trophy.svg, but the code says trophey.svg. What will the page show?
    The words A gold trophy (with a broken-picture icon). The browser cannot find a file with that exact name, so it shows the alt words instead.
  2. Where does alt show?: When does a person who can see the picture also see its alt words?
    Only when the picture does not load, or when a screen reader reads the page aloud
    alt is not shown beside a picture that loads. It stands in for the picture when it cannot be seen. A caption is a separate line of text, written as a paragraph.
  3. Good alt text: Which alt is best for a photo of the relay team holding the trophy?
    alt="The Owls relay team holding the trophy"
    alt should say what the picture shows, as you would describe it to someone on the phone. A word such as image, or the file name, tells them nothing.
  4. The missing medal: The trophy shows, but the medal does not: only its alt words appear. The picture file is called medal.svg. Click the line that causes it.
    line 4
    Line 4 asks for medal.png, but the file is medal.svg. The name, the ending after the dot and the capitals must all match the file exactly.
  5. Mix it up: Put the lines in order so that clicking the trophy picture opens the results. One line is not needed.
    see the program below
    The link's opening tag, with its href, comes first; the picture goes inside it; </a> closes the link. An <img> has no closing tag, so </img> is not needed.
    <a href="https://example.com/results">
      <img src="trophy.svg" alt="A gold trophy">
    </a>
    

Solutions

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

Modify › Change the picture

<h2>Winners</h2>
<img src="medal.svg" alt="A gold trophy" width="100">
<p>Well done, Owls!</p>

Modify › Change the alt words

<h2>Winners</h2>
<img src="medal.svg" alt="A silver medal" width="100">
<p>Well done, Owls!</p>

Modify › Change the size

<h2>Winners</h2>
<img src="medal.svg" alt="A silver medal" width="200">
<p>Well done, Owls!</p>

Make

<h1>Soccer club</h1>
<img src="ball.svg" alt="A black and white soccer ball" width="120">
<p>Training is on Thursday after school on the top oval.</p>

Stretch and support

Stretch: Add a second picture with its own alt, and make one of the pictures a link to a page.

Support: Give students the Modify starter and do the first task together, then change the alt words and the width.

Exit ticket

A student's picture does not show, only a few words. What do they check first, and what are the words?

They check that the file name in src matches the file exactly. The words are the alt text, which shows when the picture cannot load.

What each step is for

Where it leads

Next lesson names some of the elements with a class so that a CSS rule can style only those. Class idea: ask what a person using a screen reader hears when the alt says image.