title: SVG sprite. Referencing an SVG icon using <defs>, <g> and <use>
body: <p>I am trying to insert an SVG icon in HTML for later use, however when I reference it by &lt;use&gt; it doesn't appear on the webpage. I copy an the icon's SVG code and insert it in the html file. Then I move the icon's path to a separate .svg file. When I reference it later, it doesn't show up. This is a task for my studies, so I'm supposed to use this exact principle and tags: &lt;defs&gt; &lt;g&gt; and &lt;use&gt;. The first part of the code is in HTML, the second is in a separate .svg file.</p>
  <pre><code>    &lt;svg
        width=&quot;23&quot;
        height=&quot;23&quot;
        viewBox=&quot;0 0 23 23&quot;
        fill=&quot;none&quot;
        xmlns=&quot;http://www.w3.org/2000/svg&quot;
      &gt;
        &lt;use xlink:href=&quot;#vector-icons.svg#phone&quot;&gt;&lt;/use&gt;
      &lt;/svg&gt;
  
  &lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt;
    &lt;defs&gt;
      &lt;g id=&quot;phone&quot;&gt;
        &lt;path
         d=&quot;M13.9381 5C14.9149 5.19057 15.8125 5.66826 16.5162 6.37194C17.2199 7.07561 17.6976 7.97326 17.8881 8.95M13.9381 1C15.9674 1.22544 17.8597 2.13417 19.3044 3.57701C20.749 5.01984 21.6601 6.91101 21.8881 8.94M20.8881 16.92V19.92C20.8892 20.1985 20.8322 20.4742 20.7206 20.7293C20.6091 20.9845 20.4454 21.2136 20.2402 21.4019C20.035 21.5901 19.7927 21.7335 19.5289 21.8227C19.265 21.9119 18.9855 21.9451 18.7081 21.92C15.631 21.5856 12.6751 20.5341 10.0781 18.85C7.66194 17.3147 5.61345 15.2662 4.07812 12.85C2.38809 10.2412 1.33636 7.27099 1.00812 4.18C0.983127 3.90347 1.01599 3.62476 1.10462 3.36162C1.19324 3.09849 1.33569 2.85669 1.52288 2.65162C1.71008 2.44655 1.93792 2.28271 2.19191 2.17052C2.44589 2.05833 2.72046 2.00026 2.99812 2H5.99812C6.48342 1.99522 6.95391 2.16708 7.32188 2.48353C7.68985 2.79999 7.93019 3.23945 7.99812 3.72C8.12474 4.68007 8.35957 5.62273 8.69812 6.53C8.83266 6.88792 8.86178 7.27691 8.78202 7.65088C8.70227 8.02485 8.51698 8.36811 8.24812 8.64L6.97812 9.91C8.40167 12.4135 10.4746 14.4864 12.9781 15.91L14.2481 14.64C14.52 14.3711 14.8633 14.1858 15.2372 14.1061C15.6112 14.0263 16.0002 14.0555 16.3581 14.19C17.2654 14.5286 18.2081 14.7634 19.1681 14.89C19.6539 14.9585 20.0975 15.2032 20.4146 15.5775C20.7318 15.9518 20.9003 16.4296 20.8881 16.92Z&quot;
          stroke=&quot;white&quot;
          stroke-width=&quot;2&quot;
          stroke-linecap=&quot;round&quot;
          stroke-linejoin=&quot;round&quot;
        /&gt;
      &lt;/g&gt;
    &lt;/defs&gt;
  &lt;/svg&gt;
  </code></pre>