Skip to content

Commit 0a52564

Browse files
Raquel Breternitzjjgalisophschneider
authored
Update alternative-text.md (#8489)
Add guidelines to polaris.shopify.com that address how to properly use alt text. --------- Co-authored-by: jjgali <77791660+jjgali@users.noreply.github.com> Co-authored-by: Sophie Schneider <sophie.schneider@shopify.com> Co-authored-by: Sophie Schneider <thesophieschneider@gmail.com>
1 parent a991846 commit 0a52564

File tree

2 files changed

+149
-46
lines changed

2 files changed

+149
-46
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'polaris.shopify.com': patch
3+
---
4+
5+
Add new page on alt text
Lines changed: 144 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Alternative text
3-
description: Shopify aims to provide an [inclusive experience](/foundations/accessibility). Alternative text (alt text) helps people with low or loss of vision use our products.
3+
description: Alternative text (alt text) helps provide an inclusive experience for merchants who use screen readers.
44
icon: ImageAltMajor
55
keywords:
66
- speech synthesis
@@ -34,126 +34,224 @@ keywords:
3434
- alt text
3535
- accessibility feedback
3636
- accessible components
37+
- blind
3738
---
3839

39-
Generally, alt text is text replacement for an image and is often represented by the alt HTML element attribute, `alt=""`, but is also used in other scenarios.
40+
Alt text is a text replacement for an image. Generally, it is represented by the alt HTML element attribute `alt="alt text"`.
4041

41-
Screen readers announce alt text to explain images to people with low or loss of vision. Alt text is also displayed if images fail to download for some reason (for example, due to an unstable network connection).
42+
Often used by people with low or loss of vision, screen readers announce alt text to explain images. Alt text also displays if images fail to download (for example, there’s an unstable or low-bandwidth network connection).
4243

4344
Alt text should:
4445

4546
- Help visitors navigate the site
4647
- Provide an inclusive experience
47-
- Be as specific and concise as possible
48+
- Be as short and specific as possible
49+
- Be contextual to the intended message
4850

4951
---
5052

5153
## Alt text for images
5254

53-
All `<img>` tags need an alt text attribute, even if it’s empty. We need to let the screen reader know to ignore the image.
55+
Use alt text when the image conveys valuable information, such as the ability to play a demo video. Even if an image isn’t conveying meaningful information, don’t leave an `<img>` tag without an alt text element. The screen reader may try to read the filename and create a negative experience. Instead, let the screen reader know to ignore the image by setting the alt to an empty string.
5456

55-
Empty alt text attribute for images: `<img alt="" />`
57+
All `<img>` tags need an alt text attribute, even if it’s empty. For example, set an empty alt text attribute using `<img alt="" />`.
5658

5759
<!-- dodont -->
5860

5961
#### Do
6062

61-
Use alt text when the image conveys valuable information, such as the ability to play a demonstration video.
63+
```jsx
64+
<VideoThumbnail accessibilityLabel="Watch how-to video on Shopify reports." />
6265

63-
In this case, you would use:
64-
`<img alt="Watch a video on how the Shopify reports section works." />`
66+
<Thumbnail alt="Black choker necklace" />
67+
68+
<Icon accessibilityLabel="" />
69+
```
6570

6671
#### Don’t
6772

68-
Use alt text when the image doesn’t add clarity to the task. In this case, leave the alt text attribute empty: `alt=""`
73+
```jsx
74+
<VideoThumbnail accessibilityLabel="Screenshot 2022-11-07 at 3.05.55 PM" />
75+
76+
<Thumbnail alt="Sneaker.png" />
77+
78+
<Icon accessibilityLabel="IMG_1206.heic" />
79+
```
6980

7081
<!-- end -->
7182

7283
---
7384

7485
## Writing alt text
7586

76-
Alt text should always be written in plain text.
87+
Always write alt text in plain text. The average rate of listening to a screen reader is 3x slower than that of an average visual reader. Many screen reader users listen at fast speeds to make up time. When writing alt text, be as brief as possible.
7788

78-
- Use the simplest words you can. Stuck on how to replace a complicated word? Check this [A-Z list of alternative words](https://www.plainenglish.co.uk/the-a-z-of-alternative-words.html) or these [plain language tips](/content/product-content#write-for-a-7-grade-reading-level).
79-
- Avoid needless words. If you take out a word, is the phrase just as easy to understand? If yes, then cut that word.
80-
- Write concisely. Thinking about how to write for a small amount of space is a good shortcut.
81-
- Write in the [active voice](/content/grammar-and-mechanics#basics). Only use the passive voice if you want to hide who is doing the thing described.
89+
- Be concise. Think about how to write for a small amount of space or a character limit.
90+
- Use simple words. If you’re stuck on how to replace a complicated word, check this [A-Z list of alternative words](https://www.plainenglish.co.uk/the-a-z-of-alternative-words.html) or these [plain language tips](/content/product-content#write-for-a-7-grade-reading-level). Another good resource is the [Hemingway editor](https://hemingwayapp.com/).
91+
- Avoid needless words. If a phrase is still understandable without a specific word, remove it.
92+
- Remove articles like "a, an, one of," etc. whenever possible. Alt text has different grammatical rules. "Filler words" that assist understanding in speech can get in the way in alt text.
93+
- Avoid using "image of" or "photograph" unless the type of image is relevant to the context. Screenreaders already announce images with use of the `<img>` attribute.
94+
- Avoid punctuation like `!!` and emoji like 🥰. Screen readers will announce these as "exclamation point, exclamation point" and "smiling face with three hearts."
95+
- Only use acronyms you are confident your audience will understand. If using an acronym, write it with spaces in-between, like "Y M C A." Otherwise, most screen readers will try to read the acronym as a word.
96+
- Write in the [active voice](/content/grammar-and-mechanics#basics) when possible.
8297

8398
---
8499

85-
## Situations that need alt text
100+
## Alt text in context
86101

87-
### Icons
102+
It can be tricky to decide whether an image needs alt text or should be ignored by screen readers. Ask yourself:
88103

89-
[Icons](/components/images-and-icons/icon) that could be misinterpreted need an explanation, so use the `aria-label` attribute.
104+
- Is it interactive?
105+
- Does this image convey information that isn’t given elsewhere?
106+
- Does the context of the image communicate anything?
90107

91-
```html
92-
<button aria-label="Close" onclick="myDialog.close()">X</button>
108+
The same image may have different alt text depending on what it conveys.
109+
110+
For example, if you’re using a photo of sneakers purely decoratively as the hero image for a blog, tell screen readers to skip it.
111+
112+
If you’re using the photo as an example of a certain type of sneaker mentioned in the blog, then convey relevant information about the image. For example, "High-top sneaker with gum soles."
113+
114+
But if you’re using this image in a product listing, ensure shoppers know the important details of what they are buying, such as "Converse Chuck Taylor All Star Classic Black."
115+
116+
### Situations that need alt text
117+
118+
#### Icons
119+
120+
[Icons](/components/images-and-icons/icon) that could be misinterpreted need an explanation, so use the Polaris `accessibilityLabel` prop or the `aria-label` HTML attribute. For interactive icons, don’t describe the image ("magnifying glass"). Instead, describe the action ("search").
121+
122+
```jsx
123+
<Button accessibilityLabel="search" onClick={() => search()}>
124+
<Icon source={SearchMajor} accessibilityLabel="" />
125+
</Button>
93126
```
94127

95-
### Actions
128+
#### Actions
96129

97-
If space constraints require you to write calls to action without nouns, like “learn more and “apply now, give further indication of where merchants will be sent after they select.
130+
Write [clear and predictable](https://polaris.shopify.com/content/actionable-language#links) link text. If space constraints require you to write calls to action that are unclear where they take you (like "Learn more" and "Apply now"), give further indication of where merchants will be sent after they select.
98131

99-
```html
100-
<a
101-
href="{cta-url}"
102-
aria-label="Learn more about opening an online store with Shopify"
103-
>Learn more</a
132+
```jsx
133+
<Link
134+
url="https://www.shopify.com/protect"
135+
accessibilityLabel="Learn more about Fraud Protect"
104136
>
137+
Learn more
138+
</Link>
105139
```
106140

107-
### Complex images
141+
#### Complex images
108142

109-
Images with a bit more complexity need more logic in the code.
143+
Images with more complexity need some consideration. For example, groups of image elements can be described by a single text, rather than announcing each individual element.
110144

111-
```html
145+
```jsx
112146
<div role="img" aria-labelledby="star_id">
113-
<img src="fullstar.png" alt="" />
114-
<img src="fullstar.png" alt="" />
115-
<img src="halfemptystar.png" alt="" />
147+
<Stack>
148+
<Icon source={StarFilledMinor} alt="">
149+
<Icon source={StarFilledMinor} alt="">
150+
<Icon source={StarFilledMinor} alt="">
151+
<Icon source={StarOutlineMinor} alt="">
152+
<Icon source={StarOutlineMinor} alt="">
153+
</Stack>
116154
</div>
117155
<div id="star_id">3 of 5 stars</div>
118156
```
119157

158+
For more guidance, visit the W3C page on [complex images](https://www.w3.org/WAI/tutorials/images/complex/).
159+
160+
### Situations that don’t need alt text
161+
162+
Websites can sometimes be noisy for a screen reader user. While alt text is vital for an equal experience, the briefer you are, the happier your screen reader users will be. Avoid repetition and unnecessary announcements by setting `alt=""` in the scenarios that don’t need it.
163+
164+
#### Progress bars
165+
166+
Progress bars often present visual information that can also be found in the text, such as "Loading 53%." Continuously announcing that change is generally considered annoying.
167+
168+
#### Decorative elements
169+
170+
This is a broad category covering elements that are purely for aesthetic reasons, such as empty state illustrations, dividers, or hero images. If you’re unsure whether valuable information is lost, consider testing with people who regularly use a screen reader.
171+
172+
#### Images with adequate captions
173+
174+
Avoid adding repetitive alt text if an image has a caption that accurately reflects the information in the image, for example a photo of George Washington that is captioned "George Washington." If the image is presenting information that isn’t in the caption, consider adding it to the caption text. Only if this isn’t possible or appropriate should you add that information as alt text.
175+
176+
If the image has a longer description in the caption or following paragraph text, you can associate this description with the `aria-describedby` attribute.
177+
178+
#### Tracking images
179+
180+
Images that would not be visible to a sighted user should not be announced to screen-readers.
181+
120182
---
121183

122184
## Pronunciation and translation
123185

124-
Not only are we striving to make interactions with our products pleasurable, we also want to try to make the listening experience for our merchants pleasant as well. The HTML lang attribute helps speech synthesis tools figure out pronunciation and translation tools figure out what rules to use.
186+
Not only do we strive to make interactions with our products pleasant, but we want the listening experience for merchants to be positive, too. Always state the language of the page content with the HTML lang attribute. This will ensure pronunciation and translation tools will know what rules to use. If certain phrases are in a different language than the main content, you can also use the lang attribute in a `<p>` tag or similar.
187+
188+
Here’s a
189+
[standard list of language attributes](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) that you can use in your document.
125190

126191
<!-- dodont -->
127192

128193
#### Do
129194

130-
Indicate the language of the page. This example is for English.
131-
132195
```html
133196
<html lang="en"></html>
197+
<html lang="de"></html>
198+
<html lang="pt-BR"></html>
134199
```
135200

136201
#### Don’t
137202

138-
Fail to indicate the language of the page.
139-
140203
```html
141204
<html></html>
142205
```
143206

144207
<!-- end -->
145208

146-
Here’s a
147-
[standard list of language attributes](https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry) that you can use in your document.
148-
149209
---
150210

151211
## SEO
152212

153-
Alt text is a good way to increase site searchability. This applies outside of Shopify’s admin.
213+
Besides screen readers, search engines also read alt text. Alt text helps increase image ranking results and site searchability outside of Shopify’s admin.
214+
215+
When accounting for SEO in your alt text:
216+
217+
- Use logical keywords (the words that people search for).
218+
- Include relevant listing details, like if it is a limited edition or unique colorway.
219+
- Describe the image, not what you want your audience to think.
220+
- Don’t repeat your site name or brand name. Search engines will already associate your site with your images.
221+
- Avoid reducing the relevance or clarity of the alt text just to insert a keyword.
222+
- Never include unassociated lists of key words in the alt text. Instead, place those in your [meta description](https://help.shopify.com/en/manual/promoting-marketing/seo/adding-keywords#edit-the-title-and-meta-description-for-a-page).
223+
224+
<!-- dodont -->
225+
226+
#### Do
227+
228+
```jsx
229+
<Thumbnail alt="1460 Boot Limited Edition Oxblood Women's" />
230+
```
231+
232+
#### Don’t
233+
234+
```jsx
235+
<Thumbnail alt="shoes sneakers womens footwear girls sizes soles heels boots" />
236+
237+
<Thumbnail alt="Cool shoes for a night out or hot date" />
238+
```
239+
240+
<!-- end -->
241+
242+
## Resources
243+
244+
For more information on coding and alt text standards, visit the
245+
[Web Content Accessibility Guidelines (WCAG)](https://www.w3.org/WAI/intro/wcag.php) or [WebAIM Alternative Text Guidelines](https://webaim.org/techniques/alttext/).
246+
247+
## Related components
154248

155-
- Use keywords (the words that people search for) logically
156-
- Never reduce the relevance or clarity of the alt text just to insert a keyword
249+
The following Polaris components come props to set alt text or aria labels, along with specific guidance for their use:
157250

158-
For a deeper dive into coding and alt text standards, visit the
159-
[Web Content Accessibility Guidelines (WCAG)](https://www.w3.org/WAI/intro/wcag.php).
251+
- [Avatar](https://polaris.shopify.com/components/images-and-icons/avatar)
252+
- [Button](/components/actions/button)
253+
- [Icon](/components/images-and-icons/icon)
254+
- [Image](/components/images-and-icons/image)
255+
- [Link](https://polaris.shopify.com/components/navigation/link)
256+
- [Thumbnail](https://polaris.shopify.com/components/images-and-icons/thumbnail)
257+
- [Video Thumbnail](https://polaris.shopify.com/components/images-and-icons/video-thumbnail)

0 commit comments

Comments
 (0)