HTML / HTML Images and Multimedia

Using Alt Text for Accessibility

In this tutorial, you'll learn about alt text, an important aspect of web accessibility. Alt text describes the appearance and function of an image on a page, which can be crucial…

Tutorial 2 of 5 5 resources in this section

Section overview

5 resources

Introduces the inclusion of images, audio, and video in HTML.

1. Introduction

Welcome to this tutorial on using alt text for accessibility. Our goal here is to help you understand what alt text is, why it's important, and how to use it effectively to make your web content more accessible.

By the end of this tutorial, you should be able to:
- Understand what alt text is and its role in web accessibility
- Create effective and meaningful alt text for images
- Implement alt text into your HTML code

Prerequisites: Some basic knowledge of HTML is beneficial.

2. Step-by-Step Guide

Understanding Alt Text

Alt text, or alternative text, is a short description that you can add to an image tag in HTML. This text will be displayed if the image can't be loaded, and it's also used by screen readers to describe the image to visually impaired users.

Writing Effective Alt Text

When creating alt text, consider the context and function of the image. The alt text should convey the content and the purpose of the image. If the image is purely decorative, it is best practice to leave the alt text attribute empty (alt="").

Implementing Alt Text in HTML

The alt attribute is included inside the image tag in HTML. Here's a basic example:

<img src="image.jpg" alt="description of image">

In this case, "description of image" would be replaced with your alt text.

3. Code Examples

Example 1:

<img src="puppy.jpg" alt="Puppy playing in a park">

Here, the alt text tells us that the image displays a puppy playing in a park. If the image doesn't load or if a screen reader is being used, this description will be used instead.

Example 2:

<img src="logo.jpg" alt="">

In this example, the image is likely a decorative logo. The alt text is left empty, indicating to screen readers that they can skip over this image.

4. Summary

In this tutorial, we covered the importance of alt text for web accessibility, how to create meaningful alt text, and how to add alt text to an image using HTML. Next, you might want to learn about other aspects of web accessibility, such as accessible navigation or use of color.

Additional resources:
- Web Accessibility Initiative
- Google's Introduction to Web Accessibility

5. Practice Exercises

  1. Create an HTML page with three images. Add appropriate alt text to each image.

  2. Find a website with poor use of alt text. Identify the issues and suggest improvements.

Solutions:

  1. The solution will depend on the images you chose. Here's an example:
    html <img src="mountains.jpg" alt="Snowy mountain range under clear blue sky"> <img src="cat.jpg" alt="Orange tabby cat sleeping"> <img src="logo.jpg" alt="">
    In this example, the first two images have descriptive alt text, while the logo has an empty alt attribute.

  2. The solution will depend on the website you chose. Look for images without alt text, or with unhelpful or irrelevant descriptions.

By understanding and implementing good practices for alt text and other accessibility features, you'll help make the web a more inclusive place. Happy coding!

Need Help Implementing This?

We build custom systems, plugins, and scalable infrastructure.

Discuss Your Project

Related topics

Keep learning with adjacent tracks.

View category

CSS

Master CSS to style and format web pages effectively.

Explore

JavaScript

Learn JavaScript to add interactivity and dynamic behavior to web pages.

Explore

Python

Explore Python for web development, data analysis, and automation.

Explore

SQL

Learn SQL to manage and query relational databases.

Explore

PHP

Master PHP to build dynamic and secure web applications.

Explore

Popular tools

Helpful utilities for quick tasks.

Browse tools

Random Number Generator

Generate random numbers between specified ranges.

Use tool

Age Calculator

Calculate age from date of birth.

Use tool

Text Diff Checker

Compare two pieces of text to find differences.

Use tool

URL Encoder/Decoder

Encode or decode URLs easily for web applications.

Use tool

Image Compressor

Reduce image file sizes while maintaining quality.

Use tool

Latest articles

Fresh insights from the CodiWiki team.

Visit blog

AI in Drug Discovery: Accelerating Medical Breakthroughs

In the rapidly evolving landscape of healthcare and pharmaceuticals, Artificial Intelligence (AI) in drug dis…

Read article

AI in Retail: Personalized Shopping and Inventory Management

In the rapidly evolving retail landscape, the integration of Artificial Intelligence (AI) is revolutionizing …

Read article

AI in Public Safety: Predictive Policing and Crime Prevention

In the realm of public safety, the integration of Artificial Intelligence (AI) stands as a beacon of innovati…

Read article

AI in Mental Health: Assisting with Therapy and Diagnostics

In the realm of mental health, the integration of Artificial Intelligence (AI) stands as a beacon of hope and…

Read article

AI in Legal Compliance: Ensuring Regulatory Adherence

In an era where technology continually reshapes the boundaries of industries, Artificial Intelligence (AI) in…

Read article

Need help implementing this?

Get senior engineering support to ship it cleanly and on time.

Get Implementation Help