W3C home > Mailing lists > Public > www-style@w3.org > July 2010

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

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Wed, 7 Jul 2010 14:03:21 +0000
To: "www-style@w3.org list" <www-style@w3.org>, "public-fx@w3.org" <public-fx@w3.org>
Message-ID: <045A765940533D4CA4933A4A7E32597E214FC2D7@TK5EX14MBXC120.redmond.corp.microsoft.com>
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

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:37 UTC