How can I achieve changing the style of an \"use element\", defined in defs, through scripting? I was trying to move in the w3c working draft interfaces, but I lost in that laby
Nowadays, thanks to CSS variables and some clever The trick is to contain your SVG in a Notice that the style rule here points to the Note: I did experiment to get this working, it was tricky ;-)
Check out my CodePen here
div
and set the style variables in a nested tag:
div.class
?
Now in you CSS file you can make a more specific rule pointing to the within the container:
.circle-1 svg {
--stroke: yellow;
--fill: salmon;
}