HTML Validation
HTML Guides for data-uri
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
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.
Ready to validate your sites?
Start your free trial today.