Now let’s descend from the root element of a typical Inkscape SVG document to see what else is in there.
First comes the defs
element. As part of the SVG standard, it is a storage bin for things that, by themselves, are not displayed on the canvas, but may be used by other elements that are. This includes gradients, patterns, markers (arrowheads, 9.5 Markers), clipping paths, masks, filters, and so on. They are all stored as child elements of the defs
element. The SVG specification allows arbitrarily many defs
elements placed almost anywhere in the document, but Inkscape always uses a single defs
under the root svg
. Here’s an example defs
element containing a gradient:
<defs id="defs4"> <linearGradient inkscape:collect="always" id="linearGradient2798"> <stop style="stop-color:#000000;stop-opacity:1;" offset="0" id="stop2800" /> <stop style="stop-color:#000000;stop-opacity:0;" offset="1" id="stop2802" /> </linearGradient> </defs>
Adding the linearGradient
element to defs
, by itself, does not change anything on the canvas. Now, however, any object can reference (10.2.1 Sharing Gradient Definitions) this gradient for painting its fill or stroke.
Most of the stuff in defs
is kept even if no visible element uses it. (The only exceptions are the elements with the inkscape:collect
attribute with the value of always
; such elements are automatically deleted when no longer used. Inkscape often uses this flag to mark various supplemental elements it creates on its own and can safely dispose of; it will never delete anything that you created without your permission.)
This allows you to reuse things you once defined but then abandoned, but it also may lead to defs
growing larger and larger as you work on your document and try out various techniques. To remove the unused definitions from defs
, use the File ▸ Vacuum Defs command. Unfortunately, even this command may fail to completely delete all unused stuff in defs
on the first try; you may need to quit, reload the document, and vacuum defs
again for it to fully work.
The next element you will see inside an Inkscape SVG document is sodipodi:namedview
. This Inkscape-specific element holds, in its attributes, all kinds of options that are specific to this document: the zoom level and scroll position that Inkscape will use upon loading the document, the colors and spacing of the grids, various snapping modes, the current layer, document units, and so on. From within Inkscape, most of these options are settable via the File ▸ Document Properties command (3.1.2 Document Properties).
<sodipodi:namedview inkscape:window-height="950" inkscape:window-width="1280" inkscape:window-x="0" inkscape:window-y="24" inkscape:pageshadow="2" inkscape:pageopacity="0.0" bordercolor="#666666" pagecolor="#ffffff" inkscape:zoom="0.64306408" inkscape:cx="836.6226" inkscape:cy="619.40089" inkscape:current-layer="layer2" showguides="true" />
Finally, just before the actual content of the document starts, there is the metadata
element. It stores information about the author of the document, its purpose, date, license, and so on. It corresponds to the File ▸ Document Metadata dialog in Inkscape. The elements inside metadata
typically represent the information as RDF (see http://w3.org/RDF). RDF may employ many additional XML namespaces to describe different sorts of information.