Re: Using SVG properties in CSS

On Apr 30, 2008, at 1:56 AM, Erik Dahlström wrote:

>
> Hello www-svg,
>
> while I find it very interesting and fun to see David Hyatt come up  
> with new syntaxes for SVG features in CSS I still think that it  
> falls short of offering the full benefits of SVG. There are a number  
> of things that make it less useful than having a full svg document  
> that you can manipulate with script, animate with SMIL and reuse  
> parts of. And that hasn't even begun addressing the concerns about  
> being able to transparently use definitions across different  
> document formats.

I think it is misleading to call these "SVG features". Things like  
transforms and gradients are basic functionality of any modern  
graphics subsystem.  Similarly I would not call text layout or  
hyperlinks "HTML features" even though that was the first format to  
offer those features on the Web.

> I'm editor of two SVG 1.2 spec modules that cover filters and paint  
> servers. Both of which have corresponding CSS properties which could  
> very well be applied to other types of content than SVG, in fact  
> it's a stated goal. There are other modules in progress as well,  
> which could also apply to any content in a similar fashion.
>
> Having the CSS WG adopt the SVG properties defined in SVG 1.1 so  
> that they could be used in e.g HTML was proposed a long long time  
> ago. Now, since it seems to be on the table again in another form,  
> it seems indeed that the features are desired and I think it would  
> be good if that the proposal to allow SVG properties to be used in  
> CSS for other content was considered again, see for example threads  
> listed here[1].

I think this should be supported. But I don't think referencing an SVG  
resource should be required for relatively simple effects. I do not  
see the problem with offering both.

> There's some discussion on the mozilla svg newsgroup[2] about how  
> such definitions could be made, and I believe it would be similar to  
> how CSS background images are defined with regards to intrinsic size  
> etc.
>
> It's also noteworthy to see that when it comes to resources such as  
> webfonts, it seems it's not considered a problem to download  
> additional resources, but when it comes to the same using additional  
> svg files, then it's often said to be too heavy. Besides, since  
> Webkit is already supporting downloadable SVGFonts in @font-face,  
> they should be well aware that such resources may well contain other  
> resources that could be used in the stylesheet, re-using the same  
> svg resource. My question is simply: is there any good reason why  
> this shouldn't be allowed?

It should be allowed, in my opinion. (I said this on the Mozilla  
discussion thread you cited, and I don't think anyone has said it  
shouldn't be allowed). I think pure CSS syntax should also be allowed  
for cases where it makes sense. I don't think a pure CSS syntax for  
specifying all the glyphs in a font would make sense.

Web content authors go to some lengths to reduce the number of network  
transactions needed to load their page, using such techniques as CSS  
sprites. So I don't think we can just write off this concern. In the  
case of fonts, images, or other large often-binary formats, there is  
no practical way to embed the resource directly in the stylesheet. I  
don't see how referencing an XML file containing an SVG <image>  
element to mask something with an image adds value over just  
referencing the image itself (actually it subtracts value due to SVG's  
weird luminosity*alpha masking model but that's not really the key  
point).

> True, SVG is not CSS. But then again, CSS isn't meant to be SVG  
> either. At least that's my opinion.

I would not recommend adding CSS syntax for drawing pictures composed  
of scene graphs of bezier paths (other than by referincing an SVG  
image.. But I do think it is good for styling, and styles should only  
reference external resources when a simple text representation of the  
styling request will not suffice. If an author knows only HTML and  
CSS, she shouldn't have to learn an additional language to do  
something simple like a gradient.

I think SVG is great as a presentational language for vector graphics  
(and I think WebKit may be second only to Opera's Presto engine in  
native in-browser support of SVG features), but I do not think it is  
very good as a styling language for other markup languages.

Regards,
Maciej

Received on Wednesday, 30 April 2008 10:22:49 UTC