Slightly ajar

Using SVG through CSS to spice up your designs

,

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.

iTunes-esque striped tables using nth-of-typeOff to Web Directions North Tomorrow

Comments

Anonymous Thursday, February 1, 2007 12:59:36 PM

Peter Gasston writes: You're certainly teasing us with news from the internal builds! Any clue when these might be available, even as pre-Alphas?

Anonymous Thursday, February 1, 2007 3:14:23 PM

Martin Hansen writes: 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 Thursday, February 1, 2007 4:16:31 PM

Maaaan, It's can't be real! yikes Wow! up
Any screen shots? wink
Let web designer community know about this. Digg!

Jeroen HoekxJeroenH Thursday, February 1, 2007 8:40:13 PM

This is great!

Any details on the support as an image format? Does it include scripting/animation?

David Storeydstorey Thursday, February 1, 2007 11:09:19 PM

Peter: I can't comment on release schedules, but I guess when it is ready wink

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 wink

_Grey_ Thursday, February 1, 2007 11:38:32 PM

Do you think SVG "favicons" will ever make it to the web? Might be a good idea, since they can often be better than those pixelated stuff people put on the web. Just an idea I had, you might want to try that (although I'd disable scripting/animation for them altogether).

Great news, though! That's definitely a huge leap forward. People wanted this even before SVG was born wink So can they be used in all CSS properties that allow an image-url (like content)?

Jeroen HoekxJeroenH Friday, February 2, 2007 9:56:31 AM

I actually meant the use as a background image. The webkit folks also talked about it.

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.

João EirasxErath Friday, February 2, 2007 4:59:45 PM

David, is it supported as generated content ? As list bullets ? As mouse pointer ?? p

FataL Friday, February 2, 2007 5:11:49 PM

In addition to xEarth questions:
is it crash a lot currently? lol

Anonymous Friday, February 2, 2007 10:40:37 PM

Peter Gasston writes: 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 Friday, July 4, 2008 8:20:03 PM

John writes: Peter, it's already possible to use animations in background image, isn't it? (GIF, APNG)

Write a comment

You must be logged in to write a comment. If you're not a registered member, please sign up.