THE GITHTML FIELD GUIDE
Fix missing SVG symbols referenced through use
An SVG use element can reference a symbol in another file, so inline SVG markup is not necessarily self-contained. Check the href, fragment identifier, resource availability, and applicable origin restrictions. For a portable reading copy, include the needed symbol definitions inside the document or use a standalone image with an appropriate text alternative.
Identify the specific failure
The visible SVG wrapper may contain only a reference such as icons.svg#warning. Saving the wrapper without the referenced file leaves no actual shape to draw. A missing fragment inside an otherwise available sprite produces a similar symptom.
Make a narrow correction
Inspect the referenced symbol's exact identifier and its viewBox or dimensions. Copying only a path without its coordinate context can create a new clipping problem. Prefer a small, reviewed definition over embedding an entire unrelated sprite collection.
- Determine whether href refers to a same-document symbol or another resource.
- Confirm the referenced identifier exists and preserve its coordinate system.
- Replace external symbol dependencies deliberately, then test with networking unavailable.
<svg viewBox="0 0 24 24" aria-hidden="true"><use href="#warning-symbol"></use></svg>Trace a sprite reference through its file and fragment
Suppose the HTML contains an SVG with href="symbols.svg#approved". There are two separate lookups: the symbols.svg resource must be available, and that resource must contain the intended approved identifier. If the sprite loads but its identifier changed to approval-mark, the file request can succeed while the icon remains absent. Inspect both parts before changing dimensions or colors. Conversely, confirming that an approved symbol exists in a local source file does not prove that the shared copy resolves to that same file.
For a self-contained version, place a small reviewed definition in the document and reference its local fragment. Preserve the symbol's coordinate system and any necessary presentation properties. A copied shape that depends on a surrounding group transform, inherited fill, or stylesheet can look blank or displaced after extraction. Compare the complete definition against the isolated version with a contrasting test background. Keep identifier names unique when several diagrams are combined, because a repeated identifier can make a reference select an unintended definition.
External references also have loading restrictions that differ from same-document references, so do not interpret a working local fragment as proof that the original cross-file setup is allowed. The simplest reading artifact may use a normal image element or visible status text instead of a sprite mechanism. Choose based on what the symbol communicates. For a decorative check beside Approved, text can carry the result without the shape; for a meaningful diagram component, retain its geometry and explanation rather than replacing it with an unrelated decorative icon.
Verify the repaired artifact
Test the document with the original sprite unavailable. The retained icon should render, and its meaning should remain available in text.
Sources and further reading
AI-assisted writing with source-linked guidance and illustrative examples. Read our editorial approach or report a correction.