Choosing the right markup for an SVG icon
There is no single accessible markup pattern for an SVG icon, because what the icon does varies from one placement to the next. The choice follows Heather Migliorisi's research on accessible SVGs: hide a decorative icon, give a title to a stand-alone one, and let the surrounding link carry the meaning when the icon is wrapped by a link. Those three cases are shown below.

Decorative icons
An icon is decorative when it is purely presentational and its removal would lose no information. Since a visible label already names the action or content, there is nothing to announce, so the SVG is hidden from screen readers and the label does its job without the icon interfering.
<svg aria-hidden="true" ... ></svg>

Stand-alone icons
A stand-alone icon has no visible text label and is itself the meaningful action trigger. Modern browsers need only the following for this case, which applies whether the SVG sits inside a <button> or takes on the button role itself.
<svg role="img"><title>Good Label</title> ... </svg>.

Icons wrapped in a link
When an <a> element wraps the SVG and the link is the meaningful action, the quality of the link text is what matters. If the link already shows visible text, the icon is decorative. If the SVG is the entire link, give the link an accessible label:
<a href="/" aria-label="Good Label"><svg aria-hidden="true" ... ></svg></a>
Alternatively, place a <span class="screen-reader-only"> text inside the link and hide the SVG.
This approach is consistent with guidance from Heather Migliorisi, Sara Soueidan, Kitty Giraudel and Florens.



