One of the most important features of Inkscape is its ability to create various object types, with each object remembering its type and providing various controls and behaviors specific to that type (Chapter 11). Some of these object types are directly supported by SVG; for example, Inkscape’s rectangles are represented by rect
elements from SVG. But others are unique to Inkscape; for example, SVG has no special elements for spirals, stars, or 3D boxes. How can Inkscape use these object types while staying compatible with standard SVG?
The solution is the sodipodi:type
attribute. Inkscape saves a star as an universal path
element that can represent any shape, but adds to it the sodipodi:type
indicating it’s actually a star, as well as some other extension attributes storing various star-specific parameters. The path
’s standard d
attribute, meanwhile, provides an exact representation of the star’s shape:
<path sodipodi:type="star" style="fill:#ff0000;" sodipodi:sides="5" sodipodi:cx="342.85715" sodipodi:cy="703.79077" sodipodi:r1="105.75289" sodipodi:r2="40.397606" sodipodi:arg1="0.90027477" sodipodi:arg2="1.5285933" inkscape:flatsided="false" inkscape:rounded="0" inkscape:randomized="0" d="M 408.571,786.647 L 344.561,744.152 L 284.362,791.893 L 304.997,717.884 L 240.990,675.383 L 317.754,672.139 L 338.395,598.132 L 365.202,670.135 L 441.965,666.897 L 381.770,714.642 L 408.571,786.647 z" />
When loading a document with such an element, Inkscape recognizes the sodipodi:type
and, for editing, treats the object as a star rather than a path. However, when any other SVG software loads the same file, it ignores any Inkscape-specific attributes and interprets this element as a simple path which, however, looks exactly the same as the star created in Inkscape. In other words, while only Inkscape can edit the star as a star, using the standard path
as the base for this object type ensures that it remains compatible with any SVG software.