I have an SVG file containing a series of <symbol>
elements, each with unique ids. What I am trying to achieve is to use the background-image property in an HTML file to set the element with the id I choose, like this:
background-image: url(“sprite.svg#symbol_1”);
This syntax works as "src" in an <img>
or as "href" in a <use>
, but for some reason, I cannot get it to work in CSS. If I place the symbols in a <defs>
container and then set a <use>
element in the SVG file, the symbol displays when I remove the "#symbol_1", but then I lose the ability to change it.