Image Alt Text Missing — Accessibility Fix
In this tutorial, you'll learn about Image Alt Text Missing. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.
The Problem
Images without alt attributes are invisible to screen readers. Users who rely on assistive technology hear nothing and miss the information the image conveys. Missing alt text is one of the most common and most impactful Accessibility failures.
Quick Fix
Step 1: Add descriptive alt text to content images
<!-- Wrong — missing alt attribute -->
<img src="chart-q2-2026.png">
<!-- Right — descriptive alt text -->
<img src="chart-q2-2026.png"
alt="Bar chart showing Q2 2026 revenue: April $45K, May $52K, June $48K">
<!-- Screen reader output: "Bar chart showing Q2 2026 revenue..." -->
Step 2: Use empty alt for decorative images
<!-- Wrong — redundant or misleading alt -->
<img src="decorative-border.png" alt="decorative border">
<!-- Wrong — missing alt on decorative image -->
<img src="decorative-border.png">
<!-- Right — empty alt tells screen readers to ignore -->
<img src="decorative-border.png" alt="" role="presentation">
Step 3: Handle functional images (links and buttons)
<!-- Wrong — no alt for linked image -->
<a href="/products">
<img src="product-icon.svg">
</a>
<!-- Right — descriptive alt for the link target -->
<a href="/products">
<img src="product-icon.svg" alt="View our products">
</a>
<!-- Wrong — button image without text -->
<button>
<img src="search-icon.svg">
</button>
<!-- Right — alt text describes the action -->
<button>
<img src="search-icon.svg" alt="Search">
</button>
Step 4: Keep alt text concise
<!-- Wrong — overly verbose -->
alt="A photograph showing a beautiful sunset over a calm ocean with orange and purple clouds reflecting on the water surface at the beach near the palm trees"
<!-- Right — concise description -->
alt="Sunset over the ocean with palm trees"
<!-- Rule: aim for under 125 characters -->
<!-- Screen readers cut off at ~125 characters -->
Step 5: Write alt text for complex images
<!-- Wrong — empty or generic alt for chart -->
<img src="pie-chart.png" alt="Pie chart">
<!-- Right — include the data the chart shows -->
<img src="pie-chart.png"
alt="Pie chart: 45% mobile traffic, 30% desktop, 15% tablet, 10% other">
<!-- For very complex charts, provide a data table -->
<img src="detailed-chart.png"
alt="Q2 revenue comparison chart. Full data available in the table below.">
Prevention
- Every
<img>must have analtattribute (even if empty) - Write alt text that conveys the same information as the image
- Use empty
alt=""for images that add no information (decorative) - Keep alt text under 125 characters for content images
- Test with a screen reader to verify alt text quality
Common Mistakes with alt text
- Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
- Using
returnto exit a function early instead of wrapping a pure value in the monad - Mixing let bindings with <- bindings in do notation, producing type errors
These mistakes appear frequently in real-world A11Y code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro