How to Teach HTML Image Alt Text Online: A Practical Accessibility Exercise

Help beginner web developers choose alt text by image purpose, practise informative and decorative cases, and give an image-only link a useful name.

Author profile photo

By

Share this article:TwitterLinkedIn

Illustration of a tutor and learner connecting a printed photograph with a written description beside their laptops

“Describe the picture” is a useful start, but it leaves out the page around it. A photograph can carry information, an illustration can add only visual decoration, and an image inside a link can help identify a destination. Those uses call for different decisions.

This online HTML lesson gives beginners three small cases and asks them to explain each choice. Focus Room can set website rules around the browser work period; your chosen editor, preview, reference pages, and teaching conversation remain in their existing tools.

Start with purpose and surrounding content

Use the W3C Web Accessibility Initiative's alt decision tree as a reference. It considers the image's meaning and function in context, including information already available nearby. Ask learners what someone needs from this image on this page before they draft text.

For a suggested forty-minute session, allow five minutes for access and the page brief, ten for discussing roles, fifteen for editing and checking, and ten for revising and explaining. Adapt the pace to learners' HTML experience.

Prepare a small fictional workshop website with three supplied image assets: an entrance photo, a decorative flourish, and a calendar icon. Use images you have permission to use. The filenames and destinations in the code examples below are illustrative; replace them with working assets and routes in the class page.

Keep the page text visible beside each image. The same file could need different treatment in a different context. The editorial illustrations in this article support the lesson; they are not screenshots of a working editor or an accessibility test result.

Case one: convey the photo's useful information

On the fictional “Visiting the workshop” page, suppose the supplied photo clearly shows entrance steps and a ramp on the right. The surrounding text names the venue but does not describe its entrance. The photo contributes information that the text has not supplied.

An initial implementation might be:

<img src="entrance.jpg" alt="workshop.jpg">

Ask what the filename tells a visitor. Then draft a text alternative that carries the relevant visual information:

<img
  src="entrance.jpg"
  alt="Workshop entrance with steps and a ramp on the right"
>

WAI's informative-images guidance emphasizes conveying the image's meaning in context. Here, naming the entrance features is useful; describing the sky or the photographer's camera is unnecessary for the stated purpose.

Ask the learner to point to each described feature in the supplied photo. Do not add claims the picture cannot establish, such as the ramp's dimensions or compliance with a building standard. If the page needs detailed arrival instructions, write them as visible content too.

Illustration of a learner studying a printed entrance photograph and arranging notes about its relevant features

Case two: recognize decoration without removing the attribute

Now place a flourish beside a fully written workshop heading. In this scenario, it supplies visual styling and carries no additional information. Give that image an empty alternative:

<img src="flourish.png" alt="">

The empty value is deliberate. WAI's decorative-images guidance distinguishes it from omitting the attribute, which can result in some screen readers announcing a filename.

Ask learners to explain what would be lost if the flourish were absent. Under this page brief, the heading and content remain complete. If the image instead communicated a warning or category that appeared nowhere else, its role would change and the empty value would need reconsidering.

A visible caption may already supply some or all of an image's information, but the relationship requires judgment. Do not assume that every caption makes an image decorative. Read the caption, surrounding text, and image together to decide whether meaningful information remains unexpressed.

The final case uses a calendar icon as the only content inside a link to the workshop booking page. There is no adjacent link text or other naming attribute in this example.

<a href="/workshops/booking">
  <img src="calendar.png" alt="Book a workshop">
</a>

“Calendar icon” describes appearance but leaves the destination unclear. “Book a workshop” identifies the link's purpose in this fictional page. WAI's functional-images guidance recommends communicating an action or destination for this use.

Change the scenario: add visible “Book a workshop” text inside the same link. The icon may now be redundant, so an empty alt can avoid repeating that name. Ask learners to justify the changed choice from the new context rather than memorize one value for calendar images.

Inspect the result and explain the decision

For each case, have learners record the image role, their chosen alternative, and one sentence about the information or function a user needs. Then inspect the rendered class page and its HTML.

Check that the intended alt value is present, including the deliberate empty value. Inspect the image-only link's accessible name using the browser's accessibility tools. Confirm that the destination actually matches that name and that keyboard users can reach and activate the link.

These are focused checks, not complete accessibility testing. When a screen-reader check is available, report exactly what was tested and what was announced; inspecting an attribute alone is not equivalent to testing assistive technology. Do not rely on a title tooltip as a replacement for the image alternative.

Illustration of two learners comparing an image, a description card, and a destination symbol while explaining their choices

Assess relevant meaning and clarity rather than a fixed character count. End by asking each learner to explain one revision and one uncertainty they would investigate next. A good response connects the choice to the page brief and identifies any information still needed.

Prepare the browser route around the exercise

Allow the selected editor, preview, W3C references, meeting, and required sign-in hosts. Test saving, opening the preview, following the booking link, and returning to the editor before class. Save unrelated work and close off-list tabs first. The website-rule setup guide and student joining guide cover session preparation.

Focus Room matches allowed hostnames and subdomains in the participating browser while its extension session is active. A permitted editor host allows more than one project there. Off-list navigation can be redirected and reported; those events do not show whether an accessibility choice was correct.

Focus Room does not host the editor, read HTML, inspect accessibility trees, capture screens or keystrokes, grade alternatives, or control other browsers, devices, or desktop apps. Keep those checks in your teaching tools. To rehearse the lesson, create an account, test the complete route with a colleague, and end the session when the work finishes.

    How to Teach HTML Image Alt Text Online: A Practical Accessibility Exercise | Focus Room Blog