Accessibility: recommended alt-text convention for SVG and MathML?
To improve accessibility, use <title>
and <desc>
tags for SVG
elements and alttext
attribute for MathML
.
Alt text should be the verbal equivalent of the visual. It should reflect the function or story the graphic wants to convey.
Accessibility with ARIA and keyboard focus
With SVG
and MathML
, use ARIA for accessibility and consider keyboard focus for screen reader users.
SVG:
<title>
provides a simplistic identification.<desc>
offers more comprehensive detail.role="img"
communicates that the SVG is a graphical element.aria-labelledby
indicates which elements define it.
MathML:
<div>
containingrole="math"
andaria-label
offers an audible context- For complex equations not easily explainable using
aria-label
,alttext
can assist.
Add tabindex="0"
to focus these elements during keyboard navigation.
Adapting SVG and MathML for better user experience
To create an inclusive user experience when using SVGs and MathML:
1. Optimal use of SVG elements
- Keep the
<text>
as real text. Converting them to paths might lose important information. - If managing unique IDs becomes difficult, using
<img>
tags for SVGs is recommended. - Use
aria-hidden="true"
on decorative SVGs to prevent them from being read.
2. Textual alternatives for math and graphics
- Nearby alternative text such as
<figcaption>
or<p>
tags can provide an on-the-spot explanation. - For better style and accessibility, consider off-screen positioning for alternative text.
3. Wary of inconsistencies and pitfalls
- Screen reader support for
aria-label
andalttext
varies widely. Use these attributes judiciously. - Stay updated with evolving W3C specs for possible best practices.
Screen reader nuances and continued adaptation
Being aware of Screen readers' behaviour and adapting to their differences can bolster your website's accessibility:
- Depending on settings or versions, all instances of
<title>
and<desc>
could be announced by some screen readers. It's a feature, not a bug! - Screen reader support is not uniform for
aria-label
andalttext
, especially for MathML.
It's just like actual people, screen readers have their quirks too! So, continued learning and keeping updated with changes in accessibility standards is vital.
Was this article helpful?