Skip to content

Instantly share code, notes, and snippets.

Last active July 13, 2018 12:07
What would you like to do?
What to do with SVG's

Regex search:

  • style=(["|'])fill:#([a-zA-Z0-9]{3,});\1 replace with fill="#$2"
  • (class|id)=(["|'])([a-zA-Z_0-9-^-]+)\2 replace with blank

In a nuttshell:

  • Remove <title> and <decoration> if the image is “just decoration”.
  • Add role="img" aria-hidden="true" focusable="false" to the svg. Exclude aria-hidden="true" if its an infographic.
  • If its important to understand the “svg” in order to understand what the page is about, use aria-labelledby="title desc" on the SVG and use <title> and <desc> element in the SVG.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment