ImageToSVG

SVG symbol and use: Reusable Vector Definitions

SVG's symbol element lets you define shapes once and reuse them anywhere — the foundation of every scalable icon system.

Preset:
Colors:
VTracer vectorization + SVGO optimizationPrivacy protected

Defining Symbols

A symbol is an SVG element that can be instantiated with use.

  • <defs><symbol id='arrow' viewBox='0 0 24 24'><path d='M5 12h14M12 5l7 7-7 7'/></symbol></defs>
  • Symbol is not rendered until referenced with <use>
  • Symbol can have its own viewBox — crucial for correct scaling
  • Define all symbols at the top of the SVG or in a hidden sprite
  • <symbol id='...'>: the id is what you reference with href

Using Symbols with use

Reference symbols anywhere with the use element.

  • <svg class='icon'><use href='#arrow'/></svg>
  • Size: control via CSS on the wrapping <svg>: .icon { width: 24px; height: 24px; }
  • Color: set fill='currentColor' on paths inside symbol; control with CSS color
  • External sprite: <use href='/sprite.svg#arrow'/> — references from a separate file
  • Stacked use: multiple use elements with the same symbol — each can have different position/size

symbol vs g vs defs

Understanding when to use each grouping mechanism.

  • <symbol>: reusable template — not rendered until used, has own viewBox
  • <g>: simple group — rendered in place, no own viewBox
  • <defs>: storage container — anything in defs is not rendered until referenced
  • Use symbol for: icon definitions, repeated graphical elements
  • Use g for: grouping related paths in a composition for transforms/opacity
  • Use defs for: gradients, filters, clip paths, and symbols

Frequently Asked Questions

What's the difference between symbol and g in SVG?

<symbol> creates a reusable template with its own viewBox, not rendered until instantiated with <use>. <g> is a rendered group — it appears in the document where defined.

Can I override a symbol's colors at the use site?

Yes — if the symbol paths use fill='currentColor', set CSS color on the wrapping <svg> element. Each <use> can have a different color: <svg style='color:red'><use href='#icon'/></svg>

Can I scale a symbol instance independently?

Yes — add width and height to the <use> element or control the wrapping <svg> dimensions via CSS. The symbol's viewBox scales to fit the display size.

Do SVG symbols work in CSS background-image?

No — background-image SVG doesn't support cross-document references. Only inline SVG with <use> can reference symbols.

How do I animate only one use instance of a symbol?

Target the wrapping <svg> or <use> element with CSS animation. Since <use> creates shadow DOM instances, you can't style individual instances' internal paths — design symbols using currentColor for flexible per-instance styling.

Related guides

Ready to Convert Your Image to SVG?

Free online converter — no sign-up, no watermarks, results in under 3 seconds.

Try It Free — Convert Image to SVG