SVG icons

SVG icons

SVG (Scalable Vector Graphics) stores an icon as shapes and paths instead of pixels. That is why the leaf in the example stays sharp at every size.

Reasons SVG is the usual choice for interface icons:

  • It scales to any size without losing sharpness.
  • Simple icons have small file sizes.
  • Inline SVG can be styled with CSS, including its color.
  • It can be animated.

Icon fonts are an older alternative. They are also vector-based, but browsers treat them as text, which can blur their edges, and they can show as empty boxes if the font fails to load. Pro tip: if an SVG icon is the only content of a button, give the button an accessible name.