[svgwg] Where are unitless lengths allowed? What do they mean?

SimonSapin has just created a new issue for https://github.com/w3c/svgwg:

== Where are unitless lengths allowed? What do they mean? ==
In https://www.w3.org/TR/2011/REC-SVG11-20110816/single-page.html#coords-Units one can read:

> One px unit is defined to be equal to one user unit.

However I was not able to find an equivalent definition in https://svgwg.org/svg2-draft/single-page.html. Besides what it says on percentages, as far as I can tell the Units section can be summed up as "CSS units exist".

Adding the definition quoted above back to SVG 2 is probably enough to fix this, since the value of CSS units relative to each others is well-defined by css-values.

In https://www.w3.org/TR/2011/REC-SVG11-20110816/single-page.html#coords-Units also says

> When a coordinate or length value is a number without a unit identifier (e.g., "25"), then the given coordinate or length is assumed to be in user units (i.e., a value in the current user coordinate system).

But my reading of SVG2 definitions (not examples) is that unitless numbers don’t exist in syntax.

For example, https://svgwg.org/svg2-draft/single-page.html#styling-PresentationAttributes defines the `x` attribute of `rect` elements as a presentation attribute of `x` CSS property. https://svgwg.org/svg2-draft/single-page.html#geometry-X defines the value syntax for that property as `<length> | <percentage>` which does not include `<number>`. Still, many of the examples use attributes without length units. For example:

```svg
<rect id="rect1" x="25"  y="25"  width="225" height="175" fill="white" stroke="black"/>
```

Are unitless numbers intended to be only allowed in presentation attributes but not CSS (`style` attributes or stylesheets)? If so, they need separate syntax definitions, and consideration of whether this syntax should be based on the CSS tokenizer. For example, is this valid? `x="/* CSS comment */ 25"`

Please view or discuss this issue at https://github.com/w3c/svgwg/issues/379 using your GitHub account

Received on Tuesday, 16 January 2018 10:46:24 UTC