Home :: Tutorials :: SVG :: Basic Document

Below is the skeleton of a basic SVG document. This structure is used as a starting point for all examples on this site. Right-click (or option-click) here to download this file.

1

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

2

<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"

3

    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

4

<svg xmlns="http://www.w3.org/2000/svg"

5

     xmlns:xlink="http://www.w3.org/1999/xlink">

6

    <-- SVG content goes here -->

7

</svg>

Line 1 This is an XML declaration which specifies that this is an XML document that conforms to the XML 1.0 specification.
Lines 2-3 This is an XML document type declaration which specifies the grammar for this file. The SVG grammar is defined in the SVG 1.0 DTD.
Line 4 This is the root of the XML document. We create an svg element since the document type declaration states that the root element must be an svg tag. This element also defines the default XML namespace for this document.

The svg element has many attributes that effect the overall SVG document. Be sure to take a look at the SVG 1.0 specification for descriptions of these attributes and much more.

Line 5 This line defines the xlink namespace which is used to reference external images and elements within an SVG document.
Line 6 The content of your SVG document will live here.
Line 7 We close the initial svg element to complete our well-formed and valid SVG document.