Skip navigation.

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 1. February 2007, 12:59

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 1. February 2007, 15:14

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 1. February 2007, 16:16

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

JeroenH 1. February 2007, 20:40

This is great!

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

dstorey 1. February 2007, 23:09

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_ 1. February 2007, 23:38

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)?

JeroenH 2. February 2007, 09:56

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.

xErath 2. February 2007, 16:59

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

FataL 2. February 2007, 17:11

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

Anonymous 2. February 2007, 22:40

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 4. July 2008, 20:20

John writes:

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

How to use Quote function:

  1. Select some text
  2. Click on the Quote link

Write a comment

Comment
(BBcode and HTML is turned off for anonymous user comments.)

If you can't read the words, press the small reload icon.


Smilies