W3C home > Mailing lists > Public > public-cdf@w3.org > July 2006

Re: [WICD] How to create mixed SVG/CSS style sheets

From: Chris Lilley <chris@w3.org>
Date: Wed, 19 Jul 2006 15:35:38 +0200
Message-ID: <127574567.20060719153538@w3.org>
To: public-cdf@w3.org
Cc: bbos@w3.org

Hello public-cdf,

Bert wrote:


> I think the WICD Core draft is the place for this, at least I don't know 
> where else to put it...
> 
> There is an unfortunate incompatibility between the syntax of style 
> rules for SVG and the syntax defined by CSS. SVG is a Rec and thus 
> difficult to change, but the problem only occurs in style sheets that 
> mix CSS rules with SVG style rules and it can easily be avoided. I 
> think the WICD draft is the place to explain how.
> 
> The problem is that SVG allows unitless lengths in various style 
> properties (analogous to the way they are allowed in SVG attributes). 

Yes (although current browsers seem to interpret unitless lengths as
px). This is an issue primarily for CSS shorthand properties, such as
font, which is ambiguous for unitless lengths.

It also allows scientific notation where CSS does not (and CSS rejected
the request to add it).

> E.g., in an SVG style sheet, you can write
> 
>     font-size: 7
> 
> which is defined to be the same as
> 
>     font-size: 7px

(Sort of. 7px is defined to be the same as 7 user units. if that gets
scaled, the result could be very far from 7 screen pixels)

> but shorter, and, according to some, more intuitive, because the px in 
> SVG has nothing to do with a screen pixel. (In CSS, too, a px isn't the 
> same as a screen pixel, but there is usually a simple relation.)

Right.
 
> The former notation is not legal in CSS, because numbers are not 
> dimensions. (They are used for other things, such as multiplication 
> factors.)

Yes. Its clear that the main incompatibility is at the syntactic level.
The semantics are well defined.

> Thus, if a WIC document has a style sheet that mixes CSS rules (for the 
> XHTML part) and SVG style rules (for the SVG part) in a single style 
> sheet, that style sheet must use the latter notation, '7px', instead of 
> the former, '7'.

Yes. SVG 1.2 makes it clearer that the syntax in presentation attributes
(case sensitive,no CSS comments or at-rules, compatible with XSL) is not
the same as that used in style sheets (external style sheets, style
elements, style attributes).

SVG 1.2 Tiny does not use external author style sheets, so it is correct
that the issue only comes up when SVG Tiny 1.2 is combined with XHTML
and the whole is styled with CSS.

SVG Full, which does use style sheets, will impose more constraints on
what syntax can be put in style sheets for SVG compared to what can go
in formatting attributes.

The other thing to note is that creating mixed style sheets for mixed
namespace documents will be much easier once the CSS @namespace draft is
published; its good to see recent movement there.

> I think a non-normative note is enough. It's not a conformance question: 
> CSS defines how to parse numbers, the meaning is just not the same as 
> in SVG.

Can you suggest specific wording?

-- 
 Chris Lilley                    mailto:chris@w3.org
 Interaction Domain Leader
 Co-Chair, W3C SVG Working Group
 W3C Graphics Activity Lead
 Co-Chair, W3C Hypertext CG
Received on Wednesday, 19 July 2006 13:35:58 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 8 January 2008 14:10:41 GMT