Chuck's Academy

Accessibility in HTML

Accessible Images, Media, and Graphics

Images, videos, and graphics are key elements on many websites. However, if not designed correctly, they can be inaccessible to people with visual, auditory, or cognitive disabilities. In this chapter, we will explore how to make these elements accessible using alternative text, captions, descriptions, and other techniques.

Accessible Images

Images should include appropriate descriptions for users who use screen readers. This is achieved through the alt attribute in the <img> tag.

Rules for Writing Alternative Text

  1. Describe the purpose of the image, not just its content.
  2. Be brief and clear.
  3. If the image is decorative, use an empty alt attribute (alt="").

Example of an accessible image:

html
"This example uses an alt attribute that describes the image content. Users with visual disabilities can understand the purpose of the image thanks to this description."

Decorative Images

When an image doesn't add relevant information, it can be considered decorative. In this case, use an empty alt attribute so that screen readers ignore it.

html
"In this example, the empty alt attribute indicates that the image is decorative and does not require to be announced by a screen reader."

Accessible Videos

Videos should include captions, transcripts, and audio descriptions to be accessible.

Subtitles

Subtitles allow people with hearing disabilities to understand the video's content.

Example of a video with subtitles:

html
"In this example, the video includes a VTT-formatted subtitle file, which provides a transcription of the spoken content, accessible to people with hearing disabilities."

Transcripts

A transcript provides a written version of all the content of a video, including sound descriptions.

Example of a transcript:

Accessible Graphics

Graphics, like those generated with <canvas> or SVG, require additional descriptions to be accessible.

Accessible SVG

SVG elements can include descriptions using the title and desc attributes.

Example of an accessible SVG:

html
"This example uses the title and desc attributes to provide a description of the SVG graphic, ensuring that users with assistive technologies can understand its purpose."

Accessible Canvas

Content generated with <canvas> should be supplemented with an off-canvas description.

Example of a description for <canvas>:

html
"This example includes an aria-label attribute to describe the canvas content and an additional paragraph that provides more details, ensuring accessibility for users with visual disabilities."

Conclusion

Making images, videos, and graphics accessible not only improves the user experience but also ensures that more people can enjoy your content. Including appropriate descriptions, captions, and transcripts are simple but significant steps.

In the next chapter, we will explore how to ensure accessible navigation and focus management, an essential aspect for users who rely on keyboards or assistive technologies. See you there!


Ask me anything