Categories

Partners
Search


Advanced Search




PSD Tuts

flash websites

SVG Basics - Introduction
Published  07/16/2006 | SVG Viewer
   




What is SVG?

SVG stands for Scalable Vector Graphics. It is a W3C recommendation. The most comparable graphics format to it is Macromedia's Flash.

SVG is a feature rich two-dimensional graphics language which allows for the combination of vector graphic shapes, raster images (jpeg, bmp, png, etc) and text. These graphical objects can be grouped and have nested transformations, clipping paths, alpha masks and filter objects. These groups can then be used as templates for new objects. SVG documents are described in XML so they can be easily generated and read by programs.

SVG also includes a rich set of event handlers which can call scripts (usually written in Javascript) which manipulate the graphics in the SVG's Document Object Model (DOM). This approach is quite similar to Dynamic HTML (DHTML). Entire applications can easily be written in SVG. Currently, SVG lacks a standard widget set for buttons and forms but XForms will soon correct this.

SVG animation elements allow the native triggering of animation without relying on a scripting language.

This tutorial assumes you have an SVG plugin installed. If you don't have one installed please download and install a SVG plugin. The SVG plugin from Adobe is probably the best choice for Macintosh and Windows machines. Firefox 1.5 has only basic support for SVG and many examples in this tutorial will not work with it. (See: Firefox SVG Information)

This tutorial is based on the SVG 1.1 Specification which became a W3C Recommendation on January 14, 2003.

Adding SVG to Webpages

An SVG document can be added to a webpage by using either the <embed> tag or the <object> tag. The second tag is valid with current HTML and XHTML standards and the <embed> tag is not. But, not all browsers properly support the <object> tag. In fact, Apple's Safari browser used to quit when it found one and still does not properly support it. Thus, most websites use the <embed> tag despite the fact it isn't valid.

<embed src="archive/paperdolls.svg" width="800" height="600" type="image/svg+xml">
Code 1. Embed tag example

<object data="archive/paperdolls.svg" type="image/svg+xml" width="800" height="600">
Code 2. Object tag example
Article Series
This article is part 1 of a 15 part series. Other articles in this series are shown below:
  1. SVG Basics - Introduction
  2. SVG Basics - File Structure
  3. SVG Basics - Shapes
  4. SVG Basics - The 'image' Element
  5. SVG Basics - Text in SVG. The 'text' element
  6. SVG Basics - Coloring Objects in SVG
  7. SVG Basics - Organizing SVG code
  8. SVG Basics - The Basics of SVG styling
  9. SVG Basics - Gradients
  10. SVG Basics - Patterns, Markers and SVG
  11. SVG Basics - Transforms
  12. SVG Basics - Clipping
  13. SVG Basics - Masking - The 'mask' element
  14. SVG Basics - Path Element
  15. SVG Basics - JavaScript in SVG