Skip to main content

HTML Guide

Bad value for attribute “src” on element “img”: Fragment is not allowed for data: URIs according to RFC 2397.

A fragment identifier (the part after #) is not allowed in a data: URL used in an img src.

The img element accepts any valid URL in the src attribute, including data URLs per RFC 2397. However, RFC 2397 forbids fragment identifiers in data: URIs.

If you need to reference an internal fragment (e.g., an SVG symbol or id), use one of these approaches:

  • Inline the SVG in the DOM and reference its ids normally.
  • Put the SVG in a separate file and use a standard URL with a fragment (example.svg#icon).
  • Remove the fragment from the data: URL and ensure the content renders without fragment navigation.

Learn more:

Related W3C validator issues