Table of Contents
- SVG KICKSTART TUTORIAL #1
- 1. Introduction
- 2. Setting Up Your Browser
- 3. A Good Starting Point
- 4. The Immediate Benefit
- 5. Conclusion
- SVG KICKSTART TUTORIAL #2
First things first: Why does the web need a new graphics format? Aren't the JPEG and PNG formats good enough? For many applications this is quite true, raster formats like JPEG and PNG work quite nicely to represent a picture by telling your computer the exact pixel patterns that need to be displayed to convey the graphical information. The difference with SVG is that an SVG document gives your computer instructions on how to create those pixel patterns that finally get displayed rather than the actual pixel patterns. In other words, SVG images are described in higher-level terms.
The benefits of this are not necessarily obvious, so I'll outline some of them:
An SVG image is perfectly displayed at any resolution/zoom level.(Expand)
This is the "S" behind SVG: Scalable. It was probably the main driver behind creation of a new graphics format in the first place. A simple example will help to explain this. Let's say you want your web page to show a red circle with a thin blue border. If you wanted to display this in raster format, you would fire up Microsoft Paint (or Adobe Photoshop), draw the image at the desired resolution (i.e. 100x100 pixels) and save it as JPG or PNG. The problem is that if a computer is told to display this image at 400x400 resolution, it needs to expand the pixel patterns and then interpolate the pixels in between in order to make the image look smooth. Depending on the interpolation algorithm, the image may look jagged, the border of the circle may not have consistent width, etc. In an SVG document, you would simply tell the computer: "Fill the image with a red circle having a thin blue border" (in XML grammar, of course). The computer executes these instructions at any resolution.
An SVG image has semantics.(Expand)
This is partly the "V" behind SVG: Vector. When you are drawing/displaying raster images, the image is generally just a "blob of pixels", it has no meaning. With vector images, when I draw a circle, the program knows it is a circle. I can usually stretch it, change its properties (colour, stroke width), give it a name, copy it to other areas of the image, etc. If at some point I want to change the circle into a star, I can do that without affecting other parts of the image. This also means that contents of the image could be indexed by search engines, such as Google.
An SVG image is generally smaller in size and can be compressed more effectively than raster images.(Expand)
I am measuring "effectiveness" here by the fact that compression in an SVG image is lossless meaning no information is lost. In many cases, an equivalent SVG image can be an many times smaller than a corresponding raster image. However, in other cases, a raster image may end up being smaller in size, particularly if the image is complicated, abstract or particularly small (i.e. a 20x20 icon with a complicated image).
An SVG image is declarative XML and can work with other XML grammars.(Expand)
When dealing with static images, this is less of a big deal, but once you get into some of the dynamic features of SVG (in later articles, I promise!) the power unleashed here is quite impressive. Since the SVG is declarative, you can change properties of the SVG image on the fly and see the results instantly. SVG images can be scripted, they can be embedded directly in XHTML, etc.
An SVG image can be styled using CSS.(Expand)
Although there is much discussion about the current SVG specification being incompatible with CSS on some fronts, the SVG working group is attempting to make SVG usable with CSS to a great extent. This means the presentation of buttons/images can be separated from the content/behavior. As most web designers know by now: separation of presentation and content is a good thing.
One other VERY important point I should mention. The SVG spec is huge and it covers a lot of ground. In fact, one might say the advantages I've laid out above only skim the surface of what SVG is about. I only briefly mentioned the dynamic, interactive and scriptable nature of SVG above. This was intentional. These advanced features could be considered the flashy side of SVG while the above points could be considered the practical side of SVG. Either side of SVG could easily convince a web developer to begin investigating SVG. For my part, I have decided to focus on the practical side in the first few tutorials because the flashy side requires much more time investment, while the practical side can give web developers "instant" benefits TODAY.
Now that I've convinced you that SVG is a good thing for the internet, read on to learn how you can set up your Web Browser so that you can view and interact with SVG content.Next: 2. Setting Up Your Browser>>>