Local reference: fill attribute
We just make sure that using the fill attribute with a solid color is working
<circle cx="50" cy="50" r="40" fill="green" />
- Chrome
- Firefox
- Safari
- Edge
- IE11
While SVG allows to load and use remote ressources (either graphic elements or paint servers), the current state of implementation is kind of messy. This little playground intent to try to figure how things actually work and how things fit with the SVG specification.
NOTE: All the following code samples assume a view box equal to 0 0 100 100
. It is also assumed that remote ressources are loaded from the same origin (Cross-Origin is out of scope as it has to be solved at the spec level)
All these tests check the bevior of local references for solid color and paint servers
We just make sure that using the fill attribute with a solid color is working
<circle cx="50" cy="50" r="40" fill="green" />
We just make sure that using the CSS fill property with a solid color is working
<style> circle { fill: green; } </style> <circle cx="50" cy="50" r="40"/>
We just make sure that using the fill attribute with a paint server is working
<radialGradient id="#gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <circle cx="50" cy="50" r="40" fill="url(#gradient)" />
We just make sure that using the CSS fill property with a paint server is working
<radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <style> circle { fill: url(#gradient); } </style> <circle cx="50" cy="50" r="40"/>
All these tests check how browsers handle remote paint server
We apply a remote paint server through a fill attribute.
<circle cx="50" cy="50" r="40" fill="url(paint.svg#gradient)" />
<radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient>
We apply a remote paint server through a CSS fill property.
<style> circle { fill: url(paint.svg#gradient); } </style> <circle cx="50" cy="50" r="40"/>
<radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient>
All these tests check how browsers handle <use>
with local references
We use a local graphic element colored with a fill attribute
<defs> <circle id="circle" cx="50" cy="50" r="40" fill="green" /> </defs> <use xlink:href="#circle" />
We use a local graphic element with a fill attribute referencing a paint server
<defs> <radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <circle id="circle" cx="50" cy="50" r="40" fill="url(#gradient)" /> </defs> <use xlink:href="#circle" />
We use a local graphic element colored with a CSS fill property
<style> circle { fill: green; } </style> <defs> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" />
We use a local graphic element colored with a CSS fill property referencing a paint server
<style> circle { fill: url(#gradient); } </style> <defs> <radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" />
All these tests check how browsers handle <use>
with remote references
We use a remote graphic element colored with a fill attribute
<use xlink:href="graphic.svg#circle" />
<circle id="circle" cx="50" cy="50" r="40" fill="green" />
We use a remote graphic element colored with a fill attribute referencing a paint server
<use xlink:href="graphic.svg#circle" />
<radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <circle id="circle" cx="50" cy="50" r="40" fill="url(#gradient)" />
We use a remote graphic element colored with a fill attribute referencing a paint server
<use xlink:href="graphic.svg#circle" />
<g id="circle"> <radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <circle cx="50" cy="50" r="40" fill="url(#gradient)" /> </g>
We use a remote graphic element colored with a CSS fill property
<use xlink:href="graphic.svg#circle" />
<style> circle { fill: green; } </style> <circle id="circle" cx="50" cy="50" r="40" />
We use a remote graphic element colored with a CSS fill property referencing a paint server
<use xlink:href="graphic.svg#circle" />
<radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <style> circle { fill: url(#gradient); } </style> <circle id="circle" cx="50" cy="50" r="40" />
We use a remote graphic element colored with a CSS fill property, which is embedded within the <use>
Shadow tree.
<use xlink:href="graphic.svg#circle" />
<g id="circle"> <style> circle { fill: green; } </style> <circle cx="50" cy="50" r="40" /> </g>
We use a remote graphic element colored with a CSS fill property referencing a paint server, both being embedded within the <use>
Shadow tree.
<use xlink:href="graphic.svg#circle" />
<g id="circle"> <radialGradient id="gradient"> <stop offset="0%" stop-color="green" /> </radialGradient> <style> circle { fill: url(#gradient); } </style> <circle cx="50" cy="50" r="40" /> </g>
<use>
All these tests check how browsers handle style overload with <use>
on local references
We test if the fill attribute on a <use>
element is applied on a duplicated local element without any fill definition.
<defs> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" fill="green" />
We test if the fill attribute on a <use>
element is not applied on a duplicated local element with its own fill attribute
<defs> <circle id="circle" cx="50" cy="50" r="40" fill="green" /> </defs> <use xlink:href="#circle" fill="red" />
We test if the fill attribute on a <use>
element is not applied on a duplicated local element styled with a fill property
<style> circle { fill: green; } </style> <defs> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" fill="red" />
We test if the CSS fill property applied to a <use>
element is also applied on a duplicated local element without any fill definition
<style> use { fill: green; } </style> </defs> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" />
We test if the CSS fill property applied to a <use>
element is not applied on a duplicated local element without a fill attribute
<style> use { fill: red; } </style> </defs> <circle id="circle" cx="50" cy="50" r="40" fill="green" /> </defs> <use xlink:href="#circle" />
We test if the CSS fill property applied to a <use>
element is not applied on a duplicated local element styled with another CSS fill property
<style> circle { fill: green; } use { fill: red; } </style> </defs> <circle id="circle" cx="50" cy="50" r="40" /> </defs> <use xlink:href="#circle" />
<use>
All these tests check how browsers handle style overload with <use>
on remote references
We test if the fill attribute on a <use>
element is applied on a duplicated remote element without any fill definition.
<use xlink:href="graphic.svg#circle" fill="green" />
<circle id="circle" cx="50" cy="50" r="40" />
We test if the fill attribute on a <use>
element is not applied on a duplicated remote element with its own fill attribute
<use xlink:href="graphic.svg#circle" fill="red" />
<circle id="circle" cx="50" cy="50" r="40" fill="green" />
We test if the fill attribute on a <use>
element is applied on a duplicated remote element styled with a fill property
<use xlink:href="graphic.svg#circle" fill="green" />
<style> circle { fill: red; } </style> <circle id="circle" cx="50" cy="50" r="40" />
We test if the fill attribute on a <use>
element is not applied on a duplicated remote element styled with a fill property part of the Shadow tree
<use xlink:href="graphic.svg#circle" fill="red" />
<g id="circle"> <style> circle { fill: green; } </style> <circle cx="50" cy="50" r="40" /> </g>
We test if the CSS fill property applied to a <use>
element is also applied on a duplicated remote element without any fill definition
<style> use { fill: green; } </style> <use xlink:href="#circle" />
<circle id="circle" cx="50" cy="50" r="40" />
We test if the CSS fill property applied to a <use>
element is not applied on a duplicated remote element without a fill attribute
<style> use { fill: red; } </style> <use xlink:href="#circle" />
<circle id="circle" cx="50" cy="50" r="40" fill="green" />
We test if the CSS fill property applied to a <use>
element is not applied on a duplicated remote element styled with another CSS fill property
<style> use { fill: green; } </style> <use xlink:href="#circle" />
<style> circle { fill: red; } </style> <circle id="circle" cx="50" cy="50" r="40" />