XML technologies / SVG / Creating simple SVG graphics / The structure of SVG graphics / The enclosing XML tag

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

After the DTD declaration comes the SVG file’s actual code. It always begins with <svg> and ends with </svg>. Between these tags, specify the file contents using any SVG-supported tags.

The opening <svg> tag can have attributes, for example to set the graphic’s dimensions in pixels. The next listing creates an empty 500 x 500 pixel graphic, using the attributes width and height in this line:

<svg width="500" height="500">

These determine the dimensions.

Note:
Pixels are the default unit for sizes and lengths. You can also specify the unit explicitly, for example by writing <svg width="500px" height="500px">. Other units are available, as described in The coordinate system of SVG graphics. The dimensions given here determine the graphic’s size, but not necessarily its display size in the HTML page. If a different size is specified there, the entire graphic may not be visible.

   

 

 

 

back to top