Jun 19, 2026
When exporting SVG from Illustrator, individual tspan elements will be created for text blocks with font changes. The spans include coordinate attributes, preventing the natural flow of the text. This can create unwanted spacing between words. These attributes can be removed.
function stripPosition( tag ) {
return tag
.replace( /\s+x="-?[\d.]+"/g, '' )
.replace( /\s+y="-?[\d.]+"/g, '' )
.replace( /\s+xml:space="[^"]*"/g, '' );
}
Back to Notes