JSFiddle - React, Tailwind, and code Playground

HTML

<!-- l'ancre du lien doit correspondre a l'id de l'élément SVG -->
<a href="#red">Rouge</a>
<a href="#black">Noir</a>
<a href="#yellow">Jaune</a>
<a href="#blue">Bleu</a>

<div id="red">
<div id="black">
<div id="yellow">
<div id="blue">    
<svg id="monSvg" width="300px" height="300px" viewBox="0 0 300 300"  version="1.1" xmlns="http://www.w3.org/2000/svg">
    <!--un carré rouge-->
    <rect id="carre" width="300" height="300" fill="red" />
</svg>
</div>
</div>
</div>
</div>

CSS

#red:target #carre { fill: red; }
#black:target #carre { fill: black; }
#yellow:target #carre { fill: yellow; }
#blue:target #carre { fill: blue; }