I have a rect
that's 200 by 200px which I want to center in my svg
element. So I followed the flex styling I saw on other SO post (i.e. display: flex; align-items: center; justify-content: center;
). However as you can see the rectangle is not centered, but the text is.
Note: I am not allowed to use Javascript and can only hand in an HTML doc so this is why I am doing everything in HTML
<svg height="200" width="100%" fill="red" style="display: flex; align-items: center; justify-content: center;">
<g>
<rect x="0" y="0" height="200" width="200" style="fill: red"/>
<text x="50%" y="50%" alignment-baseline="middle" text-anchor="middle" font-family="Palantino" fill="black">Text</text>
</g>
</svg>