SVG text element with space not saved in IE

I want to save empty space in one SVG <text>.

This works fine with the xml: space = "save" attribute on a text element in all browsers except IE.

<text x="0" y="15" fill="red" xml:space="preserve">I love SVG!</text> 

Here is jsfiddle, try opening this script in Chrome / Firefox and in the latest IE, note that the spaces in the text of the text element are not saved in IE.

jsfiddle

Any workaround, so does this work in IE too?

+6
source share
2 answers

I think you could replace each space with &#160; (this is the unicode character of a non-breaking space ).

In javascript, it will be written as \ u00A0, though.

+14
source

If you use d3, this works well:

 .attr("style","white-space:pre") 
-1
source

Source: https://habr.com/ru/post/979679/


All Articles