[css21][css3][svg] SVG and unit-less length values

CSS2.1 and CSS3 require length values to have a unit unless the length is zero [1][2]. Non-zero lengths without a unit are invalid.

SVG, however, makes the unit to be optional for SVG properties and attributes [3]:

"For properties defined in CSS2 [CSS2], a length unit identifier must be provided. For length values in SVG-specific properties and their corresponding presentation attributes, the length unit identifier is optional."

Numerous examples in the SVG spec do use unit-less lengths [4], as do many live SVG documents [5].

This means the validity of a length property value depends on the property and/or the type of node it applies to. With mixed HTML+SVG documents bound to become more common, it would be helpful imo to describe and scope this behavior clearly in CSS modules e.g. even if/when it applied to an SVG node, the line-height property must still be parsed per CSS; thus a number value would be interpreted as font size multiplier and not a unit-less length etc.

The CSSWG must of course keep this in mind when defining new properties that are intended to apply to SVG documents. 

[1] http://www.w3.org/TR/CSS21/syndata.html#length-units
[2] http://www.w3.org/TR/css3-values/#lengths
[3] http://www.w3.org/TR/SVG/types.html#DataTypeLength
[4] http://www.w3.org/TR/SVG/styling.html#StyleAttributeExample
[5] http://www.croczilla.com/bits_and_pieces/svg/samples/butterfly/butterfly.svg

Received on Wednesday, 7 July 2010 14:03:59 UTC