I have a SVG document. In the document there is one flowRoot
element with some text and a
text-align:center
attribute. But the text will not get centered because it contains some white spaces at the start. I do not know where these white spaces come from, but there is an xml:space="preserve"
attribute in the document. After removing this attribute, the white spaces are gone. Can anybody explain to me why this is happening?
xml:space is used to handle whitespace only text nodes. The white space comes from whitespace characters, such as tabs, line breaks, or carriage returns, which are located between tags to provide formatting. Removing the preserve
value is equivalent to changing it to default
, which either collapses or replaces the whitespace characters depending on the XML processor. There is a related question with a more detailed explanation.
References