Using SVG through CSS to spice up your designs
Thursday, 1. February 2007, 11:58:42
While SVG shows at lot of promise, it hasn't yet taken off in the mainstream market. Support is still spotty, and the development tools are not quite there yet. Creating complex images using SVG by hand is beyond what most people would be willing to attempt. However there is one great use for SVG that has just been made possible in the very latest internal builds of Opera.
Internally, Opera now supports SVG as a background image in CSS through the usual background-image: url(filename.svg);
. Why is this great? Well, it is now possible to create things like gradients and hi-lights as a svg file, which are fairly easy to do even by hand, and add them as a background image to add that extra bit of refinement to your design. You could have done that previously with any image format, but SVG is scaleable at any zoom level, can cope very well with liquid layouts, can be manipulated through the DOM and doesn't require the use of an image editing application to create. One can imaging adding SVG to the CSS3 buttons I created for this blog post to remove the solidness of the background colour or make them stand out more.
Of course, it can be used for more than just gradients and patterns. It is a common technique to use extra padding and a background image to add thing like custom bullet points and presentational images that shouldn't be in the HTML markup. SVG is also perfect for creating simple images like these without too much effort, and again they'll be fully scaleable instead of becoming blocky with increased page zoom. It is not something people can jump straight into, as we must wait for both a version of Opera to be released with this functionality and other browsers to catch up, but it is something that we can look forward to and start experimenting with.



Anonymous # 1. February 2007, 12:59
You're certainly teasing us with news from the internal builds! Any clue when these might be available, even as pre-Alphas?
Anonymous # 1. February 2007, 15:14
SVG support in all browsers is something I am really looking forward to. Anyone know if IE8+ will come with this supported?
There is so much today that we use images+css for that we could have done with svg. Like rounded corners.
With SVG you can easily and programatically add things like buttons or tabs that usually require someone using photoshop/other, uploading the image and so on..
FataL # 1. February 2007, 16:16
Any screen shots?
Let web designer community know about this. Digg!
JeroenH # 1. February 2007, 20:40
Any details on the support as an image format? Does it include scripting/animation?
dstorey # 1. February 2007, 23:09
Jeroen: Do you mean using svg in the src of an img element? That works yes. Opera supports animation in SVG as can be seen on Dev.Opera but I've not played with using animation in background images. I'm scared about what some designers will do if that is possible
_Grey_ # 1. February 2007, 23:38
Great news, though! That's definitely a huge leap forward. People wanted this even before SVG was born
JeroenH # 2. February 2007, 09:56
It is sometimes useful to change a part of the background image on mouseover, but what to do when the background has a link in it? I hope there will be an option in opera:config to turn animation/scripting off, but only in background images.
xErath # 2. February 2007, 16:59
FataL # 2. February 2007, 17:11
is it crash a lot currently?
Anonymous # 2. February 2007, 22:40
BTW, the best tool I've yet found for making SVG files is Inkscape (http://www.inkscape.org/); it's an Illustrator-type vector programme that uses SVG - and it's free!
Anonymous # 4. July 2008, 20:20
Peter, it's already possible to use animations in background image, isn't it? (GIF, APNG)