Skip to content
Design System
  • Home
  • Settings
  • Styles
  • Layouts
  • Components
  • Scripts
  • Templates
  • Avatars
  • Buttons
  • Forms
  • Forms: errors
  • Forms: validation
  • Hide and show items inclusively
  • Links
  • Lists
  • SVG icons
  • SVG images
  • Tables
  • Typography
  • Utilities
  • Vertical spacing

SVG images

This section specifically covers how to use an SVG file as the src of an <img>. The use of SVG icons is covered separately.

Open this Using SVG as image source in a new tab

HTML:

<img src="/dist/assets/svg/illustration-1.svg" role="img" alt>

Note the inclusion of the role="img" attribute. Without it, some versions of Safari and iOS will skip over the image entirely and not announce the image or the alt text.

Copyright © 2025 W3C - generated 10 Jan 2025, 12:43:28 UTC

Feedback is welcome and can be submitted as a GitHub issue.