title: SVG use and gradients as fill
body: <p>I've been trying to externalize my SVG icons to a file and referencing them with markup like <code>&lt;svg&gt;&lt;use xlink:href="file.svg#icon" /&gt;&lt;/svg&gt;</code>. In theory this works really nicely, but different browsers have issues with rendering. All the browsers are able to render the svg correctly when referencing the symbol with <code>&lt;use&gt;</code> inside the file and opening the svg file's url directly.</p>
  
  <p>In short, is there a cross-browser way to get SVG <code>linearGradient</code>s working as fills for elements when referencing the symbols with <code>&lt;svg&gt;&lt;use/&gt;&lt;/svg&gt;</code> in the markup?</p>
  
  <p>I set up a plunker demonstrating the problem:
  <a href="http://plnkr.co/edit/feKvZ7?p=preview" rel="noreferrer">http://plnkr.co/edit/feKvZ7?p=preview</a></p>
  
  <p>Simplified, the markup is like the following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
      &lt;html&gt;
        &lt;body&gt;
          &lt;h1&gt;SVG sprite test&lt;/h1&gt;
          &lt;svg width="100" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
            &lt;use xlink:href="icon.svg#icon" /&gt;
          &lt;/svg&gt;
        &lt;/body&gt;
      &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the SVG file looks like this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  &lt;svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"&gt;
        &lt;defs&gt;
          &lt;linearGradient id="gradient"&gt;
            &lt;stop offset="0" stop-color="black" /&gt;
            &lt;stop offset="1" stop-color="white" /&gt;
          &lt;/linearGradient&gt;
        &lt;/defs&gt;
        &lt;symbol id="icon" viewBox="0 0 100 100"&gt;
          &lt;circle cx="50" cy="50" r="40" stroke="black" fill="url(#gradient)" /&gt;
        &lt;/symbol&gt;
      
        &lt;use id="iconuse" xlink:href="#icon" width="100" height="100" /&gt;
      
      &lt;/svg&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is what it looks like in the different browsers:
  <a href="https://i.stack.imgur.com/yZSN9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yZSN9.png" alt="Different results of rendering linear gradients for symbols in different browser"></a></p>