Learning path · Level 1 · Tutorial 6

Add Images with Appropriate Alt Text

Add an image of your own to a local page and provide an appropriate text alternative based on what the image contributes.

  • Level: Beginner
  • Duration: 13 min
  • 5 steps
Start tutorial Back to the path
Add Images with Appropriate Alt Text

Step 1 of 5

Display Your Own Local Image

Add a learner-owned image to a local HTML page by placing it in an images folder and matching its relative src path exactly.

Follow the relative path

Connect the page to an image file

An <img> element embeds an image in a page. Its src attribute identifies the image file to load.

The alt attribute provides alternative text (alt text) for the image. Include both attributes now; later steps will help you decide what the alt text should say in different contexts.

For a local page, the src value is a relative path from index.html to the image file.

See the file relationship

Diagram showing an HTML file beside an images folder containing a photograph, with an arrow from the HTML file to the photograph through the folder.

The path starts at index.html, enters images, and names the image file.

Build a small local page

Prepare your local files

On your computer, create this structure inside image-practice/:

  1. Keep the page in image-practice/index.html.
  2. Create image-practice/images/.
  3. Put a browser-supported image that you own in images/.
  4. Note its exact filename, including capitalization and extension.

The tutorial illustration is only a reference; it is not a file for your page. The code uses object.jpg as a reference filename. Replace it with your image's actual filename.

Local page starter

Save this as image-practice/index.html. Replace the reference filename and mug-specific alt text with details that match your own image before you save and refresh the page.

html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Everyday Objects</title>
</head>
<body>
  <main>
    <h1>Everyday Objects</h1>
    <img src="images/object.jpg" alt="Blue ceramic mug with a chipped rim">
  </main>
</body>
</html>
Expected output
Everyday Objects
[Your chosen image is visible; no broken-image indicator]

The image content and filename vary because you use your own file. The important result is a visible image with no broken-image indicator.

Tip

Exact names matter

Keep the attributes in this order: src, then alt. If your file is named orange-vase.PNG, its path must use the same capitalization and extension: images/orange-vase.PNG.

Check the file relationship

Complete the source path

index.html is directly inside image-practice/, and the reference photograph is directly inside its images/ folder. Complete the src value.

html
<img src="" alt="Blue ceramic mug with a chipped rim">

Practice in your browser

Use and verify your own image

Replace the reference image in your local starter with an image you own. Keep the image in image-practice/images/, save index.html, and refresh it in your browser.

Report your result in one of these forms:

  • appears: [your exact src value]
  • mismatch: [folder, filename, capitalization, or extension issue]

Also include your completed <img> line. Keep an alt attribute after src; you will refine its wording in the next step.

Write at least 20 characters (0/20).

Step 2 of 5

Write Alt Text That Preserves Meaning

Use surrounding context to write concise, informative alt text that preserves the meaning an image adds.

Choose the image's contribution

Meaning comes from context

Alternative text (alt text) gives a person who cannot see an informative image the information that image contributes here. It is not a catalog of every visible detail.

The reference photograph shows a blue ceramic mug with a chipped rim on a wooden table. When a page is about damage, the chip matters. When a page is about a blue-and-wood display, the color and surface matter instead. The photograph is unchanged; its contribution changes with the surrounding content.

One photograph, two relevant details

A comparison showing the same chipped blue mug on a wooden table, with the rim emphasized in one view and the blue-and-wood arrangement emphasized in the other.

The surrounding topic determines which meaningful detail the alt text preserves.

Context changes the wording

These examples select the detail that the reader needs from the photograph.

Two useful alternatives for the same reference photograph
Page contextInformation preservedAlt text
Checking kitchenware for damageThe chipped rimChipped rim on a blue ceramic mug
Blue ceramics displayed with natural woodThe blue mug and wooden surfaceBlue ceramic mug on a wooden table

Write only what matters

Select, rather than list

Before writing alt text, read the heading and nearby text. Ask: “What would a reader miss if this image were unavailable?” Keep that information, including a meaningful detail that nearby text does not already provide.

Be specific and concise, but do not chase an arbitrary character limit. A filename such as object.jpg and generic wording such as “image” do not communicate the photograph's meaning. For your own photograph, describe what it actually shows; do not copy the mug wording.

Example

A focused alternative

The page tells readers to inspect a mug before using it. The photograph supplies the visual evidence: damage at the rim. The alt text names that useful evidence and identifies the object.

HTML with a context-focused alt value

html
<img src="images/object.jpg" alt="Chipped rim on a blue ceramic mug">

Tip

Keep source and meaning separate

Keep src matched to your real file as you did in the previous step. Changing the alt text changes the meaning conveyed by the page; it does not change which local file the browser loads.

Practice: preserve the relevant detail

Complete the context-appropriate alternative

A section asks readers to inspect a mug's rim before using it. The reference photograph shows a blue ceramic mug with a chipped rim. Complete the informative alt value.

html
<img src="images/object.jpg" alt="">

Revise and justify

Apply the decision to your own image

In your local image-practice/index.html page, revise the alt value for your learner-owned image so it matches the image's actual content and the purpose of your Everyday Objects page.

Then respond with:

  1. Your completed <img> line, using your real filename.
  2. One sentence explaining the important detail your alt text preserves.
  3. An alt text you would use for the reference mug photograph on a page about blue ceramics displayed with natural wood, plus one sentence explaining why it differs from a damage-inspection context.

Write at least 120 characters (0/120).

Step 3 of 5

Mark Decorative Images Explicitly

Decide when an image is decorative, declare that choice with an empty alt attribute, and distinguish it from a missing alt attribute.

Decide what the image contributes

Decoration depends on context

An image is decorative when it adds no information a reader needs in that context. This is a decision about the image’s role on the page, not its file type or visual style.

For example, a photograph may be informative when it is the only source of a detail. The same photograph is decorative when nearby text already supplies every relevant detail.

A comparison diagram showing the same mug image as informative, redundant with nearby content, and lacking a declared alternative.

The pixels can be identical, but the image’s context changes what its alt text should communicate.

Tip

A practical check

Ask: “If I could not perceive this image, would I miss information needed to understand this content?” If the answer is no, use alt="" for an ordinary decorative image.

Compare nonempty, empty, and missing alt

State the choice in HTML

These three forms can look similar in a browser, but they communicate different choices to assistive technologies.

The `alt` attribute communicates an image’s role; its visual appearance does not show the difference.
Image role in contextMarkupWhat is communicated
Unique, relevant information<img src="images/object.jpg" alt="Blue ceramic mug with a chipped rim">The relevant information is available as alt text.
No needed information<img src="images/object.jpg" alt="">The image is explicitly decorative and is generally skipped.
Alternative not declared<img src="images/object.jpg">The image is unspecified; a filename or other unhelpful fallback may be announced.

Warning

Empty is not missing

Do not remove alt to make an image decorative. alt="" is an intentional empty alternative. Omitting the attribute leaves the image without a declared alternative.

Check the missing-alt misconception

Check the distinction

True or false: Removing the alt attribute is an acceptable way to mark a decorative image.

Write and justify the markup

Apply the two choices

Apply the decision to these two ordinary, non-interactive contexts using images/object.jpg:

  1. A page says only, “Here is an object from the collection.” The photograph uniquely shows that it is a blue ceramic mug with a chipped rim.
  1. A page already says, “The collection object is a blue ceramic mug with a chipped rim.” The adjacent photograph adds no other relevant information.

Write two complete img elements: one for each context. Then write one sentence correcting this claim: “Deleting alt makes an image decorative.”

Write at least 80 characters (0/80).

Step 4 of 5

Name Image-Only Links by Their Purpose

Use destination-focused alt text for image-only links, and avoid duplicate names when visible text inside the same link already communicates its purpose.

Give the link a destination-focused name

Purpose before appearance

An image-only link needs a useful name

When an <img> is the only content inside an <a> element, the image's alt text supplies that link's accessible name in these native HTML examples.

Write what following the link does—not only what the image looks like. A mug image that links to notes should communicate the notes destination, not merely describe the mug.

How the link gets its name

Diagram showing an image-only link to the Object notes section and its name in browser accessibility information.

For an image-only link, the image's alt text provides the link name.

A purpose-focused image-only link

This image-only link moves to the Object notes section. Its alt text names that destination.

html
<a href="#object-notes">
  <img src="images/object.jpg" alt="Read the object notes">
</a>

Keep visible text and alt text in the right place

Avoid duplication, not names

Visible text changes the decision

If visible link text inside the same link already communicates the purpose, and the image adds no extra meaning, use alt="" for that image. This avoids announcing duplicate information.

Text outside a link does not automatically name it. A nearby sentence may help a sighted reader understand the page, but the image-only link still needs its own accessible name.

Seeing the image in the browser does not confirm its accessible name. Inspect the link in your browser's accessibility information and look for its role and name. Panel names and locations vary by browser.

Image plus visible link text

Here, the visible words are part of the anchor, so they provide the link's accessible name. The decorative image is explicitly empty.

html
<a href="#object-notes">
  <img src="images/object.jpg" alt="">
  Read the object notes
</a>

Tip

Check the anchor boundary

Do not make an image-only link decorative just because a related sentence appears before or after it. The purpose must be available from the link itself.

Choose by link purpose

Match link context to its alternative

Match each link situation to the most appropriate alternative.

Tap an item and then its matching pair.

Apply the two cases

Complete and verify the two link names

Complete both links: one is image-only, and one includes sufficient visible text inside its anchor.

html
<a href="#object-notes">
  <img src="images/object.jpg" alt="">
</a>

<a href="#object-notes">
  <img src="images/object.jpg" >
  Read the object notes
</a>

<h2 id="object-notes">Object notes</h2>

Step 5 of 5

Apply and Check Your Image Choices

Complete and verify a local image page while applying informative, decorative, and linked-image alt text decisions.

Build the complete local page

Keep context and visual contribution separate

Use one local file in two roles. Put an image you own in image-practice/images/, then replace each images/object.jpg value below with your file’s exact name, capitalization, and extension.

For the first image, write alt text for a visual detail that the image contributes. The nearby paragraph should explain the page’s purpose without already stating that detail. That way, the image remains informative rather than redundant.

For the image-only link, keep the alternative focused on where the link goes. Its accessible name is about the destination, not the object’s appearance.

One file, two purposes

Diagram showing an informative object image adding a unique visual detail and a second copy used as a link to a notes section.

The first image adds information not already supplied by nearby text. The linked image names its destination instead.

Complete compact local page

Save this as image-practice/index.html. Replace both source paths with your learner-owned filename. Replace only the first image’s alt text with a concise detail that your image uniquely contributes; do not add that same detail to the introductory paragraph. Keep the image-only link’s destination-focused alt text and the Object notes identifier unchanged.

html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Everyday Objects</title>
</head>
<body>
  <main>
    <h1>Everyday Objects</h1>
    <p>This page collects everyday objects with details worth noticing.</p>
    <img src="images/object.jpg" alt="Blue ceramic mug with a chipped rim">

    <p>
      <a href="#object-notes">
        <img src="images/object.jpg" alt="Read the object notes">
      </a>
    </p>

    <h2 id="object-notes">Object notes</h2>
    <p>Use these notes to record observations about the object.</p>
  </main>
</body>
</html>
Expected output
Everyday Objects
This page collects everyday objects with details worth noticing.
[Informative learner-owned image]
[Linked learner-owned image]
Object notes
Use these notes to record observations about the object.

After you replace the reference filename and informative alt text, the exact image and its alternative will vary. Activating the linked image moves to the Object notes heading.

Check the finished page

Verify source, behavior, and meaning

Save the adapted file and refresh it in your browser. Check each result separately:

  1. Rendering: The informative image appears. If it does not, compare src with the file’s folder, filename, capitalization, and extension.
  2. Navigation: Activate the image-only link. It moves to the Object notes heading.
  3. Meaning: Inspect the link in your browser’s accessibility information. Its accessible name should communicate the notes destination.

Seeing an image confirms that its file rendered. It does not, by itself, confirm the accessible name of a link.

Summary

Purpose-based review

Use this checklist when reviewing your page.

  • A relative src must match the learner-owned file exactly.
  • An informative image needs alt text for the relevant detail that the image adds in its context.
  • An ordinary decorative image uses an explicit empty alt attribute.
  • For an image-only link, the image’s alt text supplies an accessible name that communicates destination or purpose.
  • A missing alt attribute is not an explicit decision that an image is decorative.

Apply the decorative-image decision

Repair a decorative-image example

The image adds no information beyond the preceding sentence and is not a link. Complete the missing markup so it is treated as decorative.

html
<p>The object label immediately above already supplies all relevant information.</p>
<img src="images/object.jpg" >

Report and complete

Final local application

Finish and save your local page before responding. It should contain your learner-owned informative image and an image-only link to Object notes. Also complete the separate decorative-image repair.

Base your report on the file you actually saved and checked. In particular, explain why the informative alt text adds a visual detail that the nearby introductory text does not already provide.

Explain your completed image choices

Write a 4–6 sentence report about your completed work. Include your informative image’s relative src; its alt text and the unique visual detail it contributes in this context; how you confirmed that the file rendered; what happened when you activated the image-only link; the accessible name you confirmed for that link and why it communicates its destination; and the markup choice used for the separate decorative-image example.

Write at least 180 characters (0/180).

Step complete

Congratulations! You completed: Add Images with Appropriate Alt Text

You completed a local image page and checked its source path, contextual informative alt text, decorative markup, and image-only link name.

Download the App now to have access to + 5000 free courses, exercises, certificates and lots of content without paying anything!

  • 100% free online courses from start to finish

    Thousands of online courses in video, ebooks and audiobooks.

  • More than 60 thousand free exercises

    To test your knowledge during online courses

  • Valid free Digital Certificate with QR Code

    Generated directly from your cell phone's photo gallery and sent to your email

Cursa app on the ebook screen, the video course screen and the course exercises screen, plus the course completion certificate