PROFESSIONALLY OPTIMIZED WEBSITES STARTING AT $995
Our team of SEO Web Design gurus are standing by to assist you achieve your online marketing goals.

+1-971-599-3330

REQUEST QUOTE
SEO Web Design, LLC aims to improve business by delivering effective solutions based on innovative technologies and professional designs. Discover the variety of services we offer and convince yourself on the basis of the latest works that we've done. We love building fresh, unique and usable websites optimized specifically for your niche.

Responsive Web Design

SEO / SEM / Social Media

Conversion Rate Optimization

Email Marketing

Online Presence Analysis

Web Hosting
Top
SEO Web Design, LLC / Web Design  / Accessible SVGs: Perfect Patterns For Screen Reader Users

Accessible SVGs: Perfect Patterns For Screen Reader Users

About The Author

Carie Fisher is an author, speaker, and developer who is passionate about the intersection of front-end code and UX, digital accessibility, and diversity in … More about Carie ↬[1][2]

Discover which SVG patterns we should avoid and which patterns are the most inclusive when comparing different combinations of OSs, browsers, and screen readers. Carie will also be running an online workshop on Accessible Front-End Patterns[3] all around front-end accessibility.

While Scalable Vector Graphics (SVGs) were first introduced in the late 90s, they have seen a massive resurgence in popularity in the last decade due to their extreme flexibility, high fidelity, and relative lightness in a world where bandwidth and performance matter more than ever. Advancements in JavaScript and the introduction of CSS media queries such @prefers-color-scheme[4] and @prefers-reduced-motion[5] have extended the functionality of SVGs way beyond their initial use case of simply displaying vector images on a website.

As SVG technology advances, our understanding of how we design and develop SVGs needs to advance as well. Part of that advancement includes considering the impact of such designs and code on actual humans, aka our end users.

This article outlines twelve distinct SVG patterns found “in the wild” and each alternative description announced when accessed by different combinations of operating systems, browsers, and screen readers.

Of course, the following examples are not meant to be an exhaustive list of all the possible patterns being used in the digital sphere, but they do highlight some of the more popular or ubiquitous SVG patterns you might encounter. Continue reading to discover which SVG patterns you should avoid and which patterns are the most inclusive!

Basic Alternative Descriptions Using The <img> Tag

The first group of four patterns utilizes the <img> tag linking out to an SVG file. This is a good choice for basic, uncomplicated images on your website, app, or other digital product. While the drawback to using this pattern is that you cannot easily control many visual elements or animations as an inline SVG, this pattern should render lighter and faster images overall and allow for easier maintenance on SVGs that you use in multiple locations.

Pattern #1: <img> + alt="[words]"

fox illustration presented in the codepen example
<img role="img" class="fox" alt="What does the fox say?" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Toicon-icon-fandom-howl.svg">

Pattern #2: <img> + role="img" + alt="[words]"

fox illustration presented in the codepen example
<img role="img" class="fox" alt="What does the fox say?" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Toicon-icon-fandom-howl.svg">

Pattern #3: <img> + role="img" + aria-label="[words]"

fox illustration presented in the codepen example
<img role="img" class="fox" aria-label="What does the fox say?" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Toicon-icon-fandom-howl.svg">

Pattern #4: <img> + role="img" + aria-labelledby="[ID]"

fox illustration presented in the codepen example
<p id="caption1" class="visually-hidden">What does the fox say?</p>
<img role="img" aria-labelledby="caption1" class="fox" src="https://upload.wikimedia.org/wikipedia/commons/3/39/Toicon-icon-fandom-howl.svg">

Basic Alternative Descriptions Using The <svg> Tag

The second group of four patterns utilizes the <svg> tag with an inline SVG file. Although adding the SVG code directly into the markup could potentially make the page a bit slower to load, that minor inefficiency will be offset by having more control over the visual elements or animations of your images. By adding your SVG to the HTML directly, you also have more options when it comes to providing image information to your screen reader users.

Pattern #5: <svg> + role="img" + <title>

fox illustration presented in the codepen example
<svg role="img" ...>
   <title>What does the fox say?</title>
   [design code]
</svg>

Pattern #6: <svg> + role="img" + <text>

fox illustration presented in the codepen example
<svg role="img" ...>
   <text class="visually-hidden" font-size="0">What does the fox say?</text>
   [design code]
</svg>

Pattern #7: <svg> + role="img" + <title> + aria-describedby="[ID]"

fox illustration presented in the codepen example
<svg role="img" aria-describedby="fox7" ...>
   <title id="fox7">What does the fox say?</title>
   [design code]
</svg>

Pattern #8: <svg> + role="img" + <title> + aria-labelledby="[ID]"

fox illustration presented in the codepen example
<svg role="img" aria-labelledby="fox8" ...>
   <title id="fox8">What does the fox say?</title>
   [design code]
</svg>

Extended Alternative Descriptions Using The <svg> Tag

The last group of four patterns utilizes the <svg> tag with an inline SVG file, much like the second group. However, in this case, we are extending the simple alternative descriptions with additional information due to the complexity of the image.

This would be a good pattern choice for more complicated images that need more explanation. However, it is important to keep in mind that there are some people with disabilities — like cognitive disorders — who might benefit from having this additional image information readily available on the screen instead of buried in the SVG code.

Depending on the type and amount of information you need to add to your SVG, you might consider taking a different approach altogether.

Pattern #9: <svg> + role="img" + <title> + <text>

fox illustration presented in the codepen example
<svg role="img" ...>
   <title>What does the fox say?</title>
   <text class="visually-hidden" font-size="0">Will we ever know?</text>
   [design code]
</svg>

Pattern #10: <svg> + role="img" + <title> + <desc>

fox illustration presented in the codepen example
<svg role="img" ...>
   <title>What does the fox say?</title>
   <desc>Will we ever know?</desc>
   [design code]
</svg>

Pattern #11: <svg> + role="img" + <title> + <desc> + aria-labelledby="[ID]"

fox illustration presented in the codepen example
<svg role="img" aria-labelledby="fox11 description11" ...>
   <title id="fox11">What does the fox say?</title>
   <desc id="description11">Will we ever know?</desc>
   [design code]
</svg>

Pattern #12: <svg> + role="img" + <title> + <desc> + aria-describedby="[ID]"

fox illustration presented in the codepen example
<svg role="img" aria-describedby="fox12 description12" ...>
   <title id="fox12">What does the fox say?</title>
   <desc id="description12">Will we ever know?</desc>
   [design code]
</svg>

See the full CodePen [Accessible SVG Pattern Comparison (Fox Version)](https://codepen.io/smashingmag/pen/dyvvbKj) by Carie Fisher[6].

See the full CodePen Accessible SVG Pattern Comparison (Fox Version)[7] by Carie Fisher[8].

SVG Pattern Winners And Losers

By running various screen readers on different combinations of operating systems and browsers, we see definite patterns emerging in the final results[9] table. There are some clear SVG pattern winners and losers, plus a few patterns somewhere in the middle that you could implement as long as you are aware of, and can accept their limitations. Looking over the results table, we can conclude the following:

Basic Alternative Descriptions Using The <img> Tag (Group 1)

Best In Show
  • Pattern 2: <img> + role="img" + alt="[words]"
  • Pattern 3: <img> + role="img" + aria-label="[words]"
Use Caution
  • Pattern 4: <img> + role="img" + aria-labelledby="[ID]"
Not Recommended
  • Pattern 1: <img> + alt="[words]"

Basic Alternative Descriptions Using The <svg> Tag (Group 2)

Best In Show
  • Pattern 5: <svg> + role="img" + <title>
  • Pattern 8: <svg> + role="img" + <title> + aria-labelledby="[ID]"
Use Caution
  • Pattern 7: <svg> + role="img" + <title> + aria-describedby="[ID]"
Not Recommended
  • Pattern 6: <svg> + role="img" + <text>

Extended Alternative Descriptions Using The <svg> Tag (Group 3)

Best In Show
  • Pattern 11: <svg> + role="img" + <title> + <desc> + aria-labelledby="[ID]"

Note: While this pattern is not perfect as it repeated alternative descriptions, it did not ignore any of the elements in the testing, unlike the “use caution” patterns.

Use Caution

  • Pattern 9: <svg> + role="img" + <title> + <text>
  • Pattern 10: <svg> + role="img" + <title> + <desc>
  • Pattern 12: <svg> + role="img" + <title> + <desc> + aria-describedby="[ID]"
Not Recommended
  • None of the patterns in this group completely failed the tests.

Testing Results

See the Pen [Testing Results](https://codepen.io/smashingmag/pen/YzZQBwG) by Carie Fisher[10].

See the Pen Testing Results[11] by Carie Fisher[12].

Wrapping Up

It is important to note that part of interpreting the results of the SVG pattern tests is understanding that creators of each screen reader have a recommended browser(s) that they fully support. This doesn’t mean you shouldn’t or couldn’t use a screen reader on a different browser, this just means that if you do, the results may not be as accurate as if you used the recommended one(s).

The pattern testing for this article did include some combinations of browsers and screen readers that may fall into the “fringe” category, but there are also notes on which combinations of operating systems, browsers, and screen readers[13] are recommended for your own testing. The results of these tests should help you make the best SVG pattern decision possible, based on your pattern needs and constraints.

A reminder that before you settle on a pattern, please make sure you know the basics of how and when to create accessible images[14] and that you fully understand the required alternative information needed[15] for the different image types.

If you need additional help deciding on which pattern to use for your environment, check out the article Good, Better, Best: Untangling The Complex World Of Accessible Patterns[16] to help you navigate the tricky waters of accessible patterns. Armed with all of this information and just a little bit of effort, your SVGs are well on their way to being more inclusive to all.

Editor’s note: You can learn best practices on accessibility with Carie in her upcoming online workshop on Accessible Front-End Patterns[17] — with guidelines, testing tools, assistive technology and inclusive design patterns. Online, and live.

Smashing Editorial(vf, il)

References

  1. ^ Carie Fisher (cariefisher.com)
  2. ^ More about Carie ↬ (www.smashingmagazine.com)
  3. ^ Accessible Front-End Patterns (smashingconf.com)
  4. ^ @prefers-color-scheme (caniuse.com)
  5. ^ @prefers-reduced-motion (caniuse.com)
  6. ^ Carie Fisher (codepen.io)
  7. ^ Accessible SVG Pattern Comparison (Fox Version) (codepen.io)
  8. ^ Carie Fisher (codepen.io)
  9. ^ final results (www.smashingmagazine.com)
  10. ^ Carie Fisher (codepen.io)
  11. ^ Testing Results (codepen.io)
  12. ^ Carie Fisher (codepen.io)
  13. ^ combinations of operating systems, browsers, and screen readers (dequeuniversity.com)
  14. ^ how and when to create accessible images (www.smashingmagazine.com)
  15. ^ required alternative information needed (www.w3.org)
  16. ^ Good, Better, Best: Untangling The Complex World Of Accessible Patterns (www.smashingmagazine.com)
  17. ^ Accessible Front-End Patterns (smashingconf.com)

Powered by WPeMatico

[email protected]

Smashing Magazine is a website and eBook publisher that offers editorial content and professional resources for web developers and web designers.

No Comments

Sorry, the comment form is closed at this time.