Icon beside visible text
<button><svg aria-hidden="true"…></svg> Add to cart</button>Images · SVG
An SVG’s treatment depends on whether it decorates text, names a control, or communicates information on its own.
The principle
Put the accessible name on the element with the role. Hide an SVG that only decorates an already-named button or link.
Four patterns
There is no single attribute recipe for every SVG. Decide whether the graphic adds meaning and whether it is itself interactive.
<button><svg aria-hidden="true"…></svg> Add to cart</button><button aria-label="Close dialog"><svg aria-hidden="true"…></svg></button><svg aria-hidden="true" focusable="false"…></svg><svg role="img" aria-labelledby="title desc"><title id="title">Service uptime</title>…</svg>Decision guide
tabindex="0" to an SVG inside a control; the button or link is the focus stop.Let that text name the control and hide the icon.
Name the button or link with an accurate action or destination.
Give the SVG image semantics plus a concise name and, when useful, a description.