SVG Document Structure

An SVG document is also an XML document: Therefore, an SVG document begins with an optional XML declaration. It also, optionally, begins with a DOCTYPE declaration.

The <svg> Element

All SVG documents have, as the root element, an <svg> element. The width and height attributes of the <svg> element define the size of the SVG image. The SVG element also has other attributes such as x and y, which are used to position an SVG graphics element. However, on an <svg> element that is the root element, any x or y attribute has no effect.

A skeleton SVG document is shown in Listing 23.8. The DOCTYPE shown is that for the SVG 1.0 Recommendation of September 2001.

Listing 23.8. A Skeleton SVG Document (SkeletonSVG.svg)
 <?xml version="1.0" ...

Get Special Edition Using XML, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.