mdn / yari

The platform code behind MDN Web Docs
Mozilla Public License 2.0
1.18k stars 503 forks source link

Improve a11y of SVG elements using ARIA #6976

Open schalkneethling opened 6 years ago

schalkneethling commented 6 years ago

After reading the tip Chris Mills recently learned with regards to setting role=img on an SVG, I did some more reading and found some additional things we can do to improve the a11y of our SVG images.

This means updating the current SVG elements of the icon system to make proper use of:

More can be read here: https://developer.paciellogroup.com/blog/2013/12/using-aria-enhance-svg-accessibility/

Bugzilla

https://bugzilla.mozilla.org/show_bug.cgi?id=1491779

caugner commented 1 year ago

Resolving this PR would mean going through all our SVGs and ...

  1. Add role="img" on the <svg> element.
  2. Add<title> element inside it with an appropriate title text.
  3. Add ` element where it makes sense with an appropriate description text.
  4. Add role="presentation" on SVG child elements like <circle>.

But probably we can ignore <svg>s that have aria-hidden="true".

caugner commented 3 months ago

Note that we have meanwhile used role="none" on some purely decorative SVGs.