If I have the arrow below and I want to place it at various locations within the svg:
<svg width="400" height="400">
<path transform="translate(150,100)" fill="black" d="M 0.5,0.5 l-100,0 -25,20 25,20 100,0 z" />
<path transform="translate(300,200)" fill="black" d="M 0.5,0.5 l-100,0 -25,20 25,20 100,0 z" />
<path transform="translate(150,300)" fill="black" d="M 0.5,0.5 l-100,0 -25,20 25,20 100,0 z" />
</svg>
https://i.sstatic.net/CDqam.png
In case I decide to change the path shape in the future, I would like to avoid repeating the d
attribute multiple times.
Is there a way to define the path's shape once and then position it at different x
, y
coordinates without using JavaScript?
A couple of considerations:
- The
d
attribute is not a CSS property so using CSS might not be an option <defs>
does not seem to support paths
Is there a method to prevent copying the entire code repeatedly besides injecting it using JavaScript?