Internal vs External SVG Symbols Using the Use Element

The SVG <use> element allows developers to instantiate reusable vector graphics defined inside <symbol> or <g> elements. The primary difference between referencing an internal versus an external SVG symbol lies in where the source definition is stored: internal references point to an ID within the same HTML/SVG document, whereas external references fetch the symbol from a standalone SVG file over the network. This distinction impacts browser caching, cross-origin security, initial page weight, and maintenance workflows.

Internal SVG Symbol Referencing

An internal SVG reference retrieves a symbol defined directly within the same HTML or SVG document. The symbol is typically housed inside a hidden SVG container within a <defs> block on the page.

Syntax

<!-- Hidden SVG sprite in the HTML document -->
<svg style="display: none;">
  <symbol id="icon-user" viewBox="0 0 24 24">
    <path d="..." />
  </symbol>
</svg>

<!-- Internal reference -->
<svg class="icon">
  <use href="#icon-user"></use>
</svg>

Key Characteristics


External SVG Symbol Referencing

An external SVG reference points to a symbol located inside an external SVG file (often called an SVG sprite sheet) hosted on a server.

Syntax

<!-- External reference to a separate file -->
<svg class="icon">
  <use href="/assets/sprite.svg#icon-user"></use>
</svg>

Key Characteristics


Direct Comparison

Feature Internal Reference (#id) External Reference (file.svg#id)
Source Location Same HTML document External .svg file
HTTP Requests 0 additional requests 1 request for the sprite file
Caching Mechanism Cached only with HTML Cached independently as static asset
CORS Sensitive No Yes (requires same-origin or CORS headers)
HTML Document Size Increases with icon count Stays minimal
Offline/Local Testing Works natively via file:// Requires a local web server

When to Use Which