Attempting to align an SVG element in the center of its parent container is proving challenging due to inconsistencies between Chrome and Safari. In Chrome, the text is perfectly centered inside the square, but not so in Safari:
<svg width="200px" height="200px">
<g transform="translate(70,70)">
<path d="M -40,-40 l 80,0 l 0,80 l -80,0 l 0,-80 z" style="fill: gray"></path>
<g>
<text text-anchor="middle" dominant-baseline="middle" style="fill: white" transform="scale(2)">
<tspan>test</tspan>
</text>
</g>
</g>
</svg>
Outcome:
https://i.sstatic.net/OzV0i.jpg
A jsFiddle was generated for this issue:
https://jsfiddle.net/yq11jot0/
Is there a reliable way to vertically center the text within the square?