Skip to content

Instantly share code, notes, and snippets.

@jdevalk
Last active July 13, 2018 12:07
Show Gist options
  • Save jdevalk/b8645a2a65253a310d4ecf5a718d9280 to your computer and use it in GitHub Desktop.
Save jdevalk/b8645a2a65253a310d4ecf5a718d9280 to your computer and use it in GitHub Desktop.
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