Ad space (banner)
🎨HTML & CSS Lessons
Lesson 18 / 50

The Basics of Accessibility (alt and aria-label)

In this lesson you'll learn the basics of accessibility using the alt attribute and aria-label, so you can build a page that's usable by everyone. This is for people searching "HTML accessibility basics."

Accessibility is consideration that makes a page usable by everyone, including people who are blind or have difficulty operating a device. You give an image a description with the alt attribute, and convey the role of an icon-only button with aria-label.

The sample code gives a logo image a description, alt="site logo image", and a symbol-only button a role description, aria-label="open the menu". This information isn't visible on screen, but people using screen-reader software have these descriptions conveyed to them as speech.

A common beginner stumbling block is writing a meaningful alt even for purely decorative images, which ends up making the information redundant. For images that are purely decorative, the correct approach is considered to be an empty alt="", so screen-reader software can skip over them.

People who use screen-reader software rely on this information to understand a page's content. Building a page that's usable by everyone, not just visually well-designed, is an essential basic stance in modern web development.

HTML & CSS
OUTPUT

💡 The preview runs entirely on this page — nothing is sent externally.

Ad space (banner)
Ad space (in-article)