In Defense of <symbol>

The deprecation of the <symbol> element is on the agenda for the Seattle SVG F2F meeting. This short page is to defend the role of the element in SVG.

The <symbol> element has long been part of SVG. There was a question at the last teleconference about if browsers handle the <symbol> element correctly (not directly displaying it even outside the <defs> section). The browsers I tested: Firefox, Chrome, Opera (Presto), handle it correctly. Here is a test:

Symbol test.

Symbol test: Left: Location of <symbol> defined outside of <defs>. If square is red then <symbol> incorrectly shown. Right: <symbol> referenced by <use> element. Square should be green.

It is used by Illustrator and Inkscape (trunk). Is important to GIS (see, for example: SJJB map icons).

Inkscape Symbol Dialog.

Inkscape Symbol dialog showing some AIGA symbols.

The <symbol> contains useful semantic information. It says that this is a symbol, intended for reuse, rather than some arbitrary object that is being duplicated. This is useful, for example, in Inkscape to build up a library of symbols used in a particular document for display in the Symbols dialog.

An arabesque design.

Repeated cloning (via <use>) of an object with no symbolic meaning.

Some logic symbols and an example of their use.

Some logic symbols with examples of their use.

If we don't value having semantic meaning in our elements, we may as well get rid of the <circle> element which just duplicates the <ellipse> element. And while we're at it, we can simplify SVG by getting rid of <ellipse> and <rect> as we already have the <path> element. And <marker> could just be special case of an SVG too.

As the topic includes the possibility of enhancing the use of the <symbol> element, Andreas writes:

It would be quite convenient if the notion of an "anchor point", could be included in SVG, separate for horizontal and vertical alignment. This is quite common in GIS where sometimes you want the center of the symbol as an anchor point, or the bottom-left, bottom-center or top-center. It would be convenient if this could be defined. As an example, the anchor point of a tower symbol would be on the bottom-center, while a circular symbol of a city would be centered horizontally and vertically.
This is shown in the QGIS dialog below. This could be done, following the example of <marker>, by adding 'refX' and 'refY'. (The corner of a symbol is currently placed at [0,0], requiring GIS users to set overflow="visible" to be able to easily center a symbol at a given point.)

QGIS Symbol Dialog.

QGIS Symbol dialog.