- From: Karl Dubost via GitHub <noreply@w3.org>
- Date: Thu, 28 May 2026 08:40:21 +0000
- To: public-svg-issues@w3.org
karlcow has just created a new issue for https://github.com/w3c/svgwg: == space trimming in the context of text/tspan == This is a test case, which is looking at trimming of spaces: (space, tab, newline) are handled by browsers: https://bugs.webkit.org/attachment.cgi?id=479861 Most browsers handled the cases the same way. But there are a couple of differences where * ⏎ - newline * ␣ - space * ⇥ - tab ## A4 Newline between tspans ``` <text text-decoration="underline"><tspan>ABC</tspan>⏎<tspan>DEF</tspan></text> ``` Safari: PASS Firefox: FAIL Chrome: FAIL ## B3. Whitespace INSIDE tspan (trailing, space) ``` <text text-decoration="underline"><tspan>ABC␣</tspan><tspan>DEF</tspan></text> ``` Safari: FAIL Firefox: FAIL Chrome: FAIL ## B3a. Whitespace INSIDE tspan (trailing, tab) ``` <text text-decoration="underline"><tspan>ABC⇥</tspan><tspan>DEF</tspan></text> ``` Safari: FAIL Firefox: FAIL Chrome: FAIL ## B3b. Whitespace INSIDE tspan (trailing, newline) ``` <text text-decoration="underline"><tspan>ABC⏎</tspan><tspan>DEF</tspan></text> ``` Safari: PASS Firefox: FAIL Chrome: FAIL **But maybe B3 and B3a are what should be done.** --- `<text>` and `<tspan>` are defined in [11.2. The ‘text’ and ‘tspan’ elements](https://w3c.github.io/svgwg/svg2-draft/text.html#TextElement) and [11.5. Text layout – Algorithm](https://w3c.github.io/svgwg/svg2-draft/text.html#TextLayoutAlgorithm). > Text layout begins by passing to a CSS-based text renderer the content of the ‘[text](https://w3c.github.io/svgwg/svg2-draft/text.html#TextElement)’ element which includes text data along with styling information and a description of one or more shapes to be filled. The ‘[text](https://w3c.github.io/svgwg/svg2-draft/text.html#TextElement)’ element is treated as a block element and its descendant ‘[tspan](https://w3c.github.io/svgwg/svg2-draft/text.html#TextElement)’, ‘[textPath](https://w3c.github.io/svgwg/svg2-draft/text.html#TextPathElement)’ and ‘[a](https://w3c.github.io/svgwg/svg2-draft/linking.html#AElement)’ elements are treated as inline elements. The CSS renderer returns a set of [typographic characters](https://w3c.github.io/svgwg/svg2-draft/text.html#TermTypographicCharacterUnit) with their positions resulting from laying out the text as if the text were absolutely positioned. Annotation 10 says: > [SVG 2 Will use CSS3 definitions for text layout (white space, bidi, etc.) that is not specific to SVG.](http://www.w3.org/2011/07/29-svg-minutes.html#item08) BASICALLY, do what CSS says do which is usually to preserve the trailing in an inline space for example: ``` <div style="text-decoration:underline;"><span>ABC␣</span><span>DEF</span></div> ``` will render `ABC DEF` and not `ABCDEF` BUT according to: > In [11.10.3.2. Legacy white-space handling, the ‘xml:space’ property](https://w3c.github.io/svgwg/svg2-draft/text.html#LegacyXMLSpace) > ‘[xml:space](https://w3c.github.io/svgwg/svg2-draft/struct.html#XMLSpaceAttribute)’ is an inheritable attribute which can have one of two values: > > **'default'** > (The initial/default value for ‘[xml:space](https://w3c.github.io/svgwg/svg2-draft/struct.html#XMLSpaceAttribute)’.) When xml:space="default", the SVG user agent will do the following using a copy of the original character data content. **First, it will remove all newline characters. Then it will convert all tab characters into space characters. Then, it will strip off all leading and trailing space characters. Then, all contiguous space characters will be consolidated**. * Remove newline characters * tabs become space characters * strip leading/trailing characters * contiguous space characters become one. ``` <text text-decoration="underline"><tspan>ABC␣</tspan><tspan>DEF</tspan></text> ``` should be rendered as `ABCDEF` which is not what is happening. **The spec contradicts itself.** And adding `xml:space="default"` doesn't trim the spaces either. Please view or discuss this issue at https://github.com/w3c/svgwg/issues/1114 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Thursday, 28 May 2026 08:40:21 UTC