Text Alternatives
Text alternatives are among the hardest parts of accessibility to get right because they rely on context and interpretation.
The Problem
Improper, duplicative, or missing alternative text can prevent screen reader users from understanding important parts of a page.
The Solution
Keep the context of the image in mind while determining alt text, sometimes it's truly not necessary. Three examples below.
Related Articles
- WebAIM - Alternative Text
- Udacity - Text Alternatives
- Scott O'Hara - How do you figure?
- Deque - How to Design Great Alt Text: An Introduction
Live Examples
Before illustrates the problem, After illustrates the solution. Click the header to see it larger in a modal.
Please note that this Before example contains inaccessible code, use this link to skip to the After Live Examplebefore
after
Code Comparison
Code diff between the before and after examples above to show the changes necessary. To copy the final source click on the 'after' path link before the diff.
source
Comparing /examples/semantics/text-alternatives/before/index.html to /examples/semantics/text-alternatives/after/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Accessibility Solutions - Semantics - Text Alternatives</title>
<link rel="stylesheet" href="../../../presentation.css" />
<link rel="stylesheet" href="text-alternatives.css" />
</head>
<body>
<h1>Text Alternative examples</h1>
<h2>Informative Images</h2>
<p>
The following SVG contains text that isn't covered in the surrounding
context,nso alternative textmeans some users missis added with that information.
</p>
<img
class="logo"
src="/img/logo.svg"
width="180"
alt="Accessibility Solutions"
/>
<h2>Decorative Images</h2>
<p>
The following SVGhabrings no additionalternative texsemantic meaning so itthat duplicatesplaintext nearby,empty
given the context it'd be best omit<code>alt</code> attributed.
</p>
<span class="decorative">
<img src="/img/logo-small.svg" width="50" alt="" /> AccessibilitySolutions" />
AccessibilitySolutions
</span>
<h2>Images with <code><figcaption></code></h2>
<p>
The image in the figure below has appropriate alternative text while the
associated <code><figcaption></code> contaginsnot aadditional replacement for anted
<code>alt</code> attribute on the associated imagentent.
</p>
<figure>
<img
class="logo"
src="/img/logo.svg"
width="180"
alt="Accessibility Solutions"
/>
<figcaption>
The Accessibility Solutions logo was created in SVG format.
</figcaption>
</figure>
</body>
</html>