Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 5 of 9
Alt Text Best Practices
Alt text is the most important accessibility attribute in HTML. Screen readers read it for visually impaired users, search engines use it for image search ranking, and it displays when images fail to load. Writing good alt text is both an accessibility requirement (WCAG) and an SEO opportunity.
Alt Text Decision Tree
Choose the right alt text based on the image's purpose:
1. Informational image - Describe the content and meaning:
alt='Bar chart showing 25% revenue increase in Q3 2025'
NOT: alt='chart' or alt='image'
2. Decorative image - Use empty alt (screen readers skip):
<img src='swirl.svg' alt=''>
NOT: alt='decorative swirl' (adds noise for blind users)
3. Image of text - Write the text:
alt='SUMMER SALE: 50% OFF all courses'
4. Complex image (charts/diagrams) - Short alt + long description:
alt='System architecture diagram'
aria-describedby='diagram-desc'
<div id='diagram-desc'>The system has 3 layers...</div>
5. Link image - Describe the destination:
<a href='/home'><img src='logo.png' alt='Priygop homepage'></a>
Rules:
⢠Never start with 'image of' or 'photo of' - screen readers already say 'image'
⢠Keep it concise (125 characters recommended)
⢠Never omit the alt attribute - screen readers will read the filename
⢠Empty alt='' is intentional; missing alt is an error
Every image requires an alt attribute - either descriptive or explicitly empty (alt="")
Warning
Never start alt text with 'image of' or 'photo of' - screen readers already announce 'image' before reading the alt text, so the user would hear 'image, image of a sunset' which is redundant and annoying. Just describe the content directly: alt='Golden sunset over ocean waves'.
Finished this lesson?