Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Image Accessibility

Images are a great way to catch attention. But we should build our pages so that everyone can use them, including people who can't see the images. Many blind and visually impaired people use a screen reader: a program that reads the page out loud. In this exercise, we will make our image accessible to them.

This is the image we created in the previous exercise:

<img src="/learn/html/cats.webp">

A screen reader can't see what is in a picture. For an image without a description, it usually reads out the file name instead, something like "cats dot webp", which doesn't help much. That is why we add the alt attribute (alternative text) with a description of the image:

<img src="/learn/html/cats.webp" alt="Six photos of domestic cats">

The screen reader then reads the description. A good description briefly says what is important in the picture.

Some images are purely decorative, for example an ornament or a background pattern, and say nothing. We give them an empty alt attribute, and screen readers then skip them:

<img src="/learn/html/ornament.webp" alt="">

The alternative text has one more use: the browser shows it when the image can't be loaded. You can try it once you have written the description: misspell the file name in src, click Run, and you will see your description instead of the photo. Then fix the name again.

Instructions

  1. 1

    Add the alt attribute to the cat image, with a short description of what is in the picture as its value.

Back

8/14

  1. 1. Attributes
  2. 2. Links
  3. 3. Quiz: Links
  4. 4. Opening Links in a New Tab
  5. 5. Relative Links
  6. 6. Images
  7. 7. Quiz: Images
  8. 8. Image Accessibility
  9. 9. Videos
  10. 10. Images as Links
  11. 11. In-Page Links
  12. 12. Page Structure
  13. 13. Main Content and Sections
  14. 14. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.