Document Structure

Defining an SVG document fragment: the 'svg' element

Overview

An SVG document fragment consists of any number of SVG elements contained within an 'svg' element, including the 'svg' element.

An SVG document fragment can range from an empty fragment (i.e., no content inside of the 'svg' element), to a very simple SVG document fragment containing a single SVG graphics element such as a 'rect', to a complex, deeply nested collection of container elements and graphics elements.

An SVG document fragment can stand by itself as a self-contained file or resource, in which case the SVG document fragment is an SVG document, or it can be embedded inline as a fragment within a parent XML document.

The following example shows simple SVG content embedded inline as a fragment within a parent XML document. Note the use of XML namespaces to indicate that the 'svg' and 'ellipse' elements belong to the SVG namespace:

This example shows a slightly more complex (i.e., it contains multiple rectangles) stand-alone, self-contained SVG document:

An SVG document fragment can only contain one single 'svg' element, this means that 'svg' elements cannot appear in the middle of SVG content.

In all cases, for compliance with either the "Namespaces in XML 1.0" or the "Namespaces in XML 1.1" Recommendations [XML-NS10][XML-NS], an SVG namespace declaration must be in scope for the 'svg' element, so that all SVG elements are identified as belonging to the SVG namespace.

For example, an 'xmlns' attribute without a prefix could be specified on an 'svg' element, which means that SVG is the default namespace for all elements within the scope of the element with the 'xmlns' attribute:

If a namespace prefix is specified on the 'xmlns' attribute (e.g., xmlns:svg="http://www.w3.org/2000/svg"), then the corresponding namespace is not the default namespace, so an explicit namespace prefix must be assigned to the elements:

Namespace declarations can also be specified on ancestor elements (illustrated in the above example). For more information, refer to the "Namespaces in XML 1.0" or the "Namespaces in XML 1.1" Recommendations [XML-NS10][XML-NS].

The 'svg' element

Attribute definitions:

version = "1.0" | "1.1" | "1.2"
Indicates the SVG language version to which this document fragment conforms.
In SVG 1.0 and SVG 1.1 this attribute had the value '1.0' or '1.1' respectively, and SVG 1.2 adds the '1.2'. See rules for version processing for further instructions, notably on handling of unsupported values.
Modifying the 'version' attribute using the DOM does not cause any change in behavior. In this case, the original value of the attribute is the one used for document processing.
Animatable: no.
baseProfile = "profile-name"
Describes the minimum SVG language profile that the author believes is necessary to correctly render the content. See rules for baseProfile processing for further instructions.
This specification defines the values 'none' and 'tiny'. The value 'full' corresponds to all features in the SVG language; for SVG 1.1, this corresponds to the language features defined in the SVG 1.1 specification. The value 'basic' was defined in the SVG Mobile 1.1 specification. This specification corresponds to baseProfile="tiny" and version="1.2". A value of 'none' provides no information about the minimum language profile that is necessary to render the content.
If the attribute is not specified, the effect is as if a value of 'none' were specified.
Modifying the 'baseProfile' attribute using the DOM does not cause any change in behavior. In this case, the original value of the attribute is the one used for document processing.
Animatable: no.
width = "<length>"
The intrinsic width of the SVG document fragment. Together with the 'height', 'viewBox' and 'preserveAspectRatio' attributes it defines the intrinsic aspect ratio and (unless both width and height are percentages) the intrinsic size of the svg element. See the initial viewport.
A negative value is unsupported. A value of zero disables rendering of the element.
If the attribute is not specified, the effect is as if a value of "100%" were specified.
Animatable: yes.
height = "<length>"
The intrinsic height of the SVG document fragment.
A negative value is unsupported. A value of zero disables rendering of the element.
If the attribute is not specified, the effect is as if a value of "100%" were specified.
Animatable: yes.
viewBox = "<list-of-numbers>" | "none"
See attribute definition for description.
Animatable: yes.
preserveAspectRatio = "[defer] <align> [<meet>]"
See attribute definition for description.
Animatable: yes.
snapshotTime = "<clock-value>" | "none"
Indicates a moment in time which is most relevant for a still-image of the animated SVG content. This time may be used as a hint to the SVG user agent for rendering a still-image of an animated SVG Document, such as a preview. A value of 'none' means that no 'snapshotTime' is available. See an example of using the 'snapshotTime' attribute.
If the attribute is not specified, the effect is as if a value of 'none' was specified.
Animatable: no.
playbackOrder = "forwardOnly" | "all"
Indicates whether it is possible to seek backwards. In earlier versions of SVG there was no need to put restrictions on the direction of seeking but with the newly introduced facilities for long-running documents (e.g. the 'discard' element) there is sometimes a need to restrict this.
If 'playbackOrder' is set to 'forwardOnly', the content will probably contain 'discard' elements or scripts that destroy resources, thus seeking back in the document's timeline may result in missing content. If 'playbackOrder' is 'forwardOnly', the content should not provide a way, through hyperlinking or script, of seeking backwards in the timeline. Similarly the UA should disable any controls it may provide in the user interface for seeking backwards. Content with 'playbackOrder' = 'forwardOnly' that provides a mechanism for seeking backwards in time may result in undefined behavior or a document that is in error.
'forwardOnly'
This file is intended to be played only in the forward direction, sequentially, therefore seeking backwards should not be allowed.
'all'
Indicates that the document is authored appropriately for seeking in both directions.
The lacuna value is 'all'.
Animatable: no.
timelineBegin = "onLoad" | "onStart"
Controls the initialization of the timeline for the document.
The 'svg' element controls the Document Timeline, which is the timeline of the 'svg' element's time container. For progressively loaded animations, the author would typically set this attribute to 'onStart', thus allowing the timeline to begin as the document loads, rather than waiting until the complete document is loaded.
'onLoad'
The document's timeline starts the moment the load event for the rootmost 'svg' element is triggered.
'onStart'
The document's timeline starts at the moment the rootmost 'svg' element's start tag [XML10, XML11] is fully parsed and processed.
The lacuna value is 'onLoad'.
Animatable: no.
contentScriptType = "content-type"
Identifies the default scripting language for the given document. This attribute sets the default scripting language for all the instances of script in the document fragment. This language must be used for all scripts that do not specify their own scripting language. The value content-type specifies a media type, per Multipurpose Internet Mail Extensions (MIME) PartTwo [RFC2046]. The lacuna value is "application/ecmascript".
Animatable: no.
zoomAndPan = "magnify" | "disable"
See attribute definition for description.
Animatable: No
focusable = "true" | "false" | "auto"
See attribute definition for description.
Animatable: Yes
Navigation Attributes
See definition.

Note that 'animateMotion' and 'animateTransform' are legal as children to 'svg' but don't apply to 'svg' parents (since the 'svg' element doesn't have a 'transform' attribute). They only have any effect if the xlink:href attribute is attached to them so they point to other elements.

Content produced by illustration programs originally targeted at print often has a fixed width and height, which will prevent it scaling for different display resolutions. The first example below has a fixed width and height in pixels, and no 'viewBox'.

Normally, SVG content is designed to be scalable. In order for the SVG content to scale automatically to fill the available viewport, it must include a 'viewBox' attribute on the 'svg' element. This describes the region of world coordinate space (the initial user coordinate system) used by the graphic. This attribute thus provides a convenient way to design SVG documents to scale-to-fit into an arbitrary viewport.

The second example is scalable, using a 'viewBox' rather than a fixed width and height.

Below is an example of 'snapshotTime'. An SVG user agent is displaying a number of SVG files in a directory by rendering a thumbnail image. It uses the 'snapshotTime' as the time to render when generating the image, thus giving a more representative static view of the animation. The appearance of the thumbnail for an SVG user agent that honors the 'snapshotTime' and for an SVG user agent that does not is shown below the example (UA which generates thumbnails based on 'snapshotTime' at the left, UA which doesn't generate thumbnails based on 'snapshotTime' at the right, e.g. a static viewer).

Snapshot time thumbnails

Grouping: the 'g' element

Overview

The 'g' element is a container element for grouping together related graphics elements.

Grouping constructs, when used in conjunction with the 'title' and 'desc' elements, provide information about document structure and semantics. Documents that are rich in structure may be rendered graphically, as speech, or as braille, and thus promote accessibility.

A group of elements, as well as individual objects, can be given a name using the 'xml:id' attribute. Named groups are needed for several purposes such as animation and re-usable objects.

An example:

A 'g' element can contain other 'g' elements nested within it, to an arbitrary depth. Thus, the following is possible:

Any element that is not contained within a 'g' is treated (at least conceptually) as if it were in its own group.

The 'g' element

Attribute definitions:

focusable = "true" | "false" | "auto"
See attribute definition for description.
Animatable: Yes
Navigation Attributes
See definition.

The 'defs' element

The 'defs' element is a container element for referenced elements. For understandability and accessibility reasons, it is recommended that, whenever possible, referenced elements be defined inside of a 'defs'. For performance reasons, authors should put the 'defs' element before other document content, so that all resources are available to be referenced.

The content model for 'defs' is the same as for the 'g' element; thus, any element that can be a child of a 'g' can also be a child of a 'defs', and vice versa.

Elements that are descendants of a 'defs' are not rendered directly; they are prevented from becoming part of the rendering tree just as if the 'defs' element were a 'g' element and the 'display' property were set to none. Note, however, that the descendants of a 'defs' are always present in the source tree and can be referenced by other elements. The actual value of the 'display' property on the 'defs' element or any of its descendants does not change the rendering of these elements or prevent these elements from being referenced.


Creators of SVG content are encouraged to place all elements which are targets of local IRI references (except of course for animation targets) within a 'defs' element which is a direct child of one of the ancestors of the referencing element. For example:

In the document above, the linear gradient is defined within a 'defs' element which is the direct child of the 'svg' element, which in turn is an ancestor of the 'rect' element which references the linear gradient. Thus, the above document conforms to the guideline.

The 'discard' element

The 'discard' element allows authors to specify the time at which particular elements are to be discarded, thereby reducing the resources required by an SVG UA. This is particularly useful for the SVG viewers to handle long-running documents. This element will not be processed by static SVG viewers.

The 'discard' element may occur wherever the animate element may.

Attribute definitions:

xlink:href = "<XMLRI>"
An IRI reference to the element to discard. See the definition of target element.
Note that if the target element is not part of the current SVG document fragment then whether discard shall remove the target element or not is defined by the host language.
If the 'xlink:href' attribute is not provided, then the target element will be the immediate parent element of the discard element.
Animatable: no.
begin = "begin-value-list"
See attribute definition for description. If the attribute is not specified, the effect is as if a value of "0s" were specified. This indicates that the target element should be discarded immediately.
Animatable: no.

The 'discard' element has an implicit simple duration of 'indefinite'. As soon as the element's active duration starts, the SVG user agent discards the element identified by the 'xlink:href' attribute. The removal operation acts as if the method removeChild were called on the parent of the target element with the target element as parameter. The SVG user agent must remove the target node as well as all of its attributes and descendants.

After removal of the target element, the 'discard' element is no longer useful. It must also be discarded following the target element removal. If the target element did not exist, the 'discard' element must still be removed following activation.

Seeking backwards in the timeline must not re-insert the discarded elements. Discarded elements are intended to be completely removed from memory. So, authors are encouraged to set the 'playbackOrder' attribute to forwardOnly when using the 'discard' element.

The 'discard' element itself can be discarded prior to its activation, in which case it will never trigger the removal of its own target element. UA's must allow the 'discard' element to be the target of another 'discard' element.

The following example shows simple usage of the 'discard' element. The list below describes relevant happenings in the document timeline of this example:

At time = 0:
When the document timeline starts, the blue ellipse starts to move down the page.
At time = 1 second:
The red rectangle starts moving up the page.
At time = 2 seconds:
The animateTransform on the ellipse ends. The ellipse and its children are also discarded, as it is the target element of a discard with begin='2'. The green polygon starts to move across the page.
At time = 3 seconds:
The animation on the red rectangle ends. The rectangle and its children are discarded as it is the target of a discard element with begin='3'.
At time = 4 seconds:
The animation on the green triangle ends. The green polygon and its children are discarded as it is the target of a discard element with begin='4'.

The 'title' and 'desc' elements

Each container element or graphics element in an SVG document may contain one or more of each of the 'title' and 'desc' descriptive elements. The 'title' element must contain a short title for the container or graphics element containing it. This short title must provide information supplementary to the rendering of the element, but will normally not be sufficient to replace it. The 'desc' element contains a longer, more detailed description for the container or graphics element containing it. This description must be usable as replacement content for cases when the user cannot see the rendering of the SVG element for some reason.

Authors should always provide at least a 'title', and preferably a 'desc', as an immediate child element to the 'svg' element within an SVG document. The 'title' child element to an 'svg' element serves the purposes of identifying the content of the given SVG document fragment. Since users often consult documents out of context, authors should provide context-rich titles. Thus, instead of a title such as "Introduction", which doesn't provide much contextual background, authors should supply a title such as "Introduction to Medieval Bee-Keeping" instead. For reasons of accessibility, SVG user agents should always make the content of the 'title' child element to the 'svg' element available to users (See the User Agent Accessibility Guidelines 1.0 [UAAG]). The mechanism for doing so depends on the SVG user agent (e.g., as a caption, spoken).

When descriptive elements are present, alternate presentations of the document are possible, both visual and aural, which display the 'title' and 'desc' elements but do not display graphics elements.

For both the 'title' and the 'desc' element, the content must be plain text. To provide structured data in other markup languages, authors should use the 'metadata' or 'foreignObject' elements instead, as appropriate.

Note that the 'title' element is distinct in purpose from the 'xlink:title' attribute of the 'a' element. The 'xlink:title' attribute content is intended not to describe the current resource, but the nature of the linked resource.

Applicable 'title' and 'desc'

Normally, the descriptive elements that describe a container element or graphics element are direct children of that element. However, SVG documents can have a rich structure, with nested elements each potentially containing 'title' or 'desc' child elements, as well as 'use' elements with 'title' or 'desc' in both the 'use' element itself and in the referenced content. Because of this complex structure, and because the descriptive elements may or may not be present at any level, the applicable descriptive elements for any given content is determined by the structure, as described here.

For each container element or graphics element, the applicable descriptive elements shall be those that are most deeply nested in that document fragment, without taking into account descriptive elements in any 'use' element shadow trees. If the document fragment has no descriptive elements, and it is a 'use' element, , the applicable descriptive elements shall be those contained in the shadow tree. If no descriptive elements is found in the document fragment or any shadow tree, the applicable descriptive elements shall be the nearest ancestor descriptive elements. This algorithm allows authors to reuse descriptive elements defined in referenced resources when desired, or to override them as needed, as well as to describe whole groups of elements.

Multiple 'title' and 'desc' elements

It is strongly recommended that at most one 'title' and at most one 'desc' element appear as a child of any particular element, and that these elements appear before any other child elements (except possibly 'metadata' elements) or character data content. If SVG user agents need to choose among multiple 'title' or 'desc' elements for processing (e.g., to decide which string to use for a tooltip), the user agent shall choose the first of each of the available descriptive elements as the applicable elements or elements.

Authors may wish to deliberately provide multiple descriptive elements, such as to provide alternate content for different languages. In this case, the author should use conditional processing attributes to allow the user agent to select the best choice according to the user's preferences. For example, the 'systemLanguage' attribute, with or without the 'switch' element, will determine the applicable descriptive elements.

User Interface Behavior for 'title' and 'desc'

When the current SVG document fragment is rendered as SVG on visual media, 'title' and 'desc' elements are not rendered as part of the canvas. However, SVG user agents should expose this information upon demand by the user. It is strongly recommended that the text content of the applicable 'title' and 'desc' elements is displayed in a highly visible manner supported by the user agent, such as in a tooltip or status bar, when the pointing device is hovered over the described element or elements, or when the described element is given focus (e.g., through keyboard or pointer navigation). If a tooltip is provided, the user agent is recommended to display the applicable title and descriptions on separate lines, title first, with font styling that distinguishes the two. For long descriptions, the tooltip may wrap the text, and truncate longer passages to a reasonable length.

When an element with descriptive elements is itself the child of an 'a' element with an 'xlink:title' attribute, the user agent should display as much of the available information as possible. The user agent is suggested to display the 'xlink:title' attribute value on a separate line, with a label to identify it, such as "link: ". Commonly, many user agents display the URI of the link (i.e., the value of the 'xlink:href' attribute) in the status bar or other display area. This information is important, and should not be overridden by any descriptive element content, but may be supplemented by such content.

The rootmost title element should be used as the document title, and for stand-alone SVG documents, the title should not be displayed as a tooltip, but rather in the browser chrome (as appropriate for the user agent). For embedded SVG documents, such as an SVG image referenced in an HTML document, displaying the title and description as a tooltip is more appropriate, and the user agent should do so.

If a user agent does expose the title and description content visually, such as in a tooltip, then it should allow the author or user to prevent this presentation by setting the 'display' property to none. Note that no other presentation properties apply to the descriptive elements.

If a user agent is an accessibility tool, all available descriptions of the currently focused or hovered element should be exposed to the user in a categorical manner, such that the user may selectively access the various descriptions. The 'desc' element, in particular, may be given different semantic distinctions by use of values in the 'role' attribute, such as the ARIA ontology values aria:description for textual equivalentsof the graphics, and aria:tooltip for giving instructions to the user.

 
 

The following is an example. In typical operation, the SVG user agent would not render the 'title' and 'desc' elements but would render the remaining contents of the 'g' element.

The 'use' element

Any 'g' or graphics element is potentially a template object that can be re-used (i.e. "instantiated") in the SVG Document via a 'use' element, thus creating an instance tree. The 'use' element references another element and indicates that the graphical contents of that element is to be included and drawn at that given point in the document.

Unlike 'animation', the 'use' element cannot reference entire files.

Besides what is described about the 'use' element in this section important restrictions for 'use' can be found in the Reference Section.

The 'use' element has optional attributes 'x' and 'y' which are used to place the referenced element and its contents into the current coordinate system.

The effect of a 'use' element is as if the SVG Element contents of the referenced element were deeply cloned into a separate non-exposed DOM tree which had the 'use' element as its parent and all of the 'use' element's ancestors as its higher-level ancestors. Because the cloned DOM tree is non-exposed, the SVG Document Object Model (DOM) only contains the 'use' element and its attributes. The SVG DOM does not show the referenced element's contents as children of the 'use' element. The deeply-cloned tree, also referred to as the shadow tree, is then kept in synchronization with the contents of the referenced element, so that any animation, DOM manipulation, or non-DOM interactive state occurring on the referenced element are also applied to the 'use' element's deeply-cloned tree.

Relative IRIs on nodes in shadow trees are resolved relative to any 'xml:base' on the node itself, then recursively on any 'xml:base' on their parentNode, and finally any 'xml:base' on the ownerDocument if there is no parentNode.

Property inheritance works as if the referenced element had been textually included as a deeply cloned child of the 'use' element. The referenced element inherits properties from the 'use' element and the 'use' element's ancestors. An instance of a referenced element does not inherit properties from the referenced element's original parents.

The behavior of the 'visibility' property conforms to this model of property inheritance. Thus, a computed value of visibility='hidden' on a 'use' element does not guarantee that the referenced content will not be rendered. If the 'use' element has a computed value of visibility='hidden' and the element it references specifies visibility='hidden' or visibility='inherit', then that element will be hidden. However, if the referenced element instead specifies visibility='visible', then that element will be visible even if the 'use' element specifies visibility='hidden'.

If an event listener is registered on a referenced element, then the actual target for the event will be the SVGElementInstance object within the "instance tree" corresponding to the given referenced element.

The event handling for the non-exposed tree works as if the referenced element had been textually included as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects. The event's target and currentTarget attributes are set to the SVGElementInstance that corresponds to the target and current target elements in the referenced subtree. An event propagates through the exposed and non-exposed portions of the tree in the same manner as it would in the regular document tree: first going to the target of the event, then bubbling back through non-exposed tree to the 'use' element and then back through regular tree to the rootmost 'svg' element in the bubbling phase.

An element and all its corresponding SVGElementInstance objects share an event listener list. The currentTarget attribute of the event can be used to determine through which object an event listener was invoked.

Animations on a referenced element will cause the instances to also be animated.

As listed in the Reference Section the 'use' element is not allowed to reference an 'svg' element

A 'use' element has the same visual effect as if the 'use' element were replaced by the following generated content:

  • In the generated content, the 'use' will be replaced by 'g', where all attributes from the 'use' element except for 'x', 'y', 'xml:base' and 'xlink:href' are transferred to the generated 'g' element. An additional transformation translate(x,y) is appended to the end (i.e., right-side) of the 'transform' attribute on the generated 'g', where 'x' and 'y' represent the values of the 'x' and 'y' attributes of the 'use' element. The referenced object and its contents are deep-cloned into the generated tree.

except for resolution of relative IRI references as noted above and until the referenced elements are modified. Note also that any changes to the used element are immediately reflected in the generated content.

When a 'use' references another element which is another 'use' or whose content contains a 'use' element, then the deep cloning approach described above is recursive. However, a set of references that directly or indirectly reference a element to create a circular dependency is an error, as described in the References section.

Attribute definitions:

x = "<coordinate>"
The x-axis coordinate of one corner of the rectangular region into which the referenced element is placed.
If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
y = "<coordinate>"
The y-axis coordinate of one corner of the rectangular region into which the referenced element is placed.
If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
xlink:href = "<XMLRI>"
An IRI Reference to an element/fragment within an SVG document. An empty attribute value (xlink:href="") disables rendering of the element. If the attribute is not specified, the effect is as if an empty value ("") was specified.
Animatable: yes.
focusable = "true" | "false" | "auto"
See attribute definition for description.
Animatable: Yes
Navigation Attributes
See definition.

Below are two examples of the 'use' element, for another example see use and animation example.

Example 05_13 below has a simple 'use' on a 'rect'.

The visual effect would be equivalent to the following document:

Example 05_17 illustrates what happens when a 'use' has a transform attribute.

The visual effect would be equivalent to the following document:

Example use-bubble-example-1.svg illustrates four cases of event bubbling with use elements. In case 1, all instances of the 'rect' element are filled blue on mouse over. For cases 2 and 3, in addition to the 'rect' elements being filled blue, a black stroke will also appear around the referencing rectangle on mouse over. In case 4, all the rectangles turn blue on mouse over, and a black stroke appears on mouse click.

Example use-bubble-example-2.svg illustrates event bubbling with nested use elements. On mouse over, the 'rect' element is filled blue and displays a green and black ring.

Example image-use-base.svg illustrates the handling of relative IRI references. All three use elements result in the same image being displayed, http://a.example.org/aaa/bbb/ddd/foo.jpg


The 'image' element

The 'image' element indicates that the contents of a complete document are to be rendered into a given rectangle within the current user coordinate system. In SVG Tiny 1.2, the 'image' must reference content that is a raster image format, such as PNG and JPG. SVG Tiny 1.2 does not allow an SVG document to be referenced by the 'image' element; instead, authors should use the 'animation' element for referencing SVG Documents. Conforming SVG viewers must support PNG and JPEG image file formats. Other image file formats may be supported.

For details of the required JPEG support see the JPEG Support Appendix. PNG support is required as defined the PNG specification [PNG].

The result of processing an 'image' is always a four-channel RGBA result. When an 'image' element references a raster image file such as PNG or JPEG files which only has three channels (RGB), then the effect is as if the object were converted into a 4-channel RGBA image with the alpha channel uniformly set to 1. For a single-channel raster image, the effect is as if the object were converted into a 4-channel RGBA image, where the single channel from the referenced object is used to compute the three color channels and the alpha channel is uniformly set to 1.

The 'image' element supports the 'opacity' property for controlling the image opacity. The 'fill-opacity' property does not affect the rendering of an image.

An 'image' element establishes a new viewport for the referenced file as described in Establishing a new viewport. The bounds for the new viewport are defined by attributes 'x', 'y', 'width' and 'height'. The placement and scaling of the referenced image are controlled by the 'preserveAspectRatio' attribute on the 'image' element.

The value of the 'viewBox' attribute to use when evaluating the 'preserveAspectRatio' attribute is defined by the referenced content. For content that clearly identifies a 'viewBox' that value should be used. For most raster content (PNG, JPEG) the bounds of the image should be used (i.e. the 'image' element has an implicit 'viewBox' of "0 0 raster-image-width raster-image-height"). Where no value is readily available the 'preserveAspectRatio' attribute is ignored and only the translate due to the 'x' and 'y' attributes of the viewport is used to display the content.

For example, if the 'image' element referenced a PNG or JPEG and preserveAspectRatio="xMinYMin meet", then the aspect ratio of the raster would be preserved (which means that the scale factor from the image's coordinates to the current user space coordinates would be the same for both X and Y), the raster would be sized as large as possible while ensuring that the entire raster fits within the viewport, and the top left of the raster would be aligned with the top left of the viewport as defined by the attributes 'x', 'y', 'width' and 'height' on the 'image' element.  If the value of 'preserveAspectRatio' was 'none' then aspect ratio of the image would not be preserved. The image would be fitted such that the top/left corner of the raster exactly aligns with coordinate ('x', 'y') and the bottom/right corner of the raster exactly aligns with coordinate ('x'+'width','y'+'height').

The SVG specification does not specify when an image that is not being displayed should be loaded. An SVG user agent is not required to load image data for an image that is not displayed (e.g. is is outside the initial document viewport), except when that image is contained inside a subtree for which 'externalResourcesRequired' is set to true. However, it should be noted that this may cause a delay when an image becomes visible for the first time. In the case where an author wants to suggest that the SVG user agent loads image data before it is displayed, they should use the 'prefetch' element.

Note that an SVG user agent may choose to incrementally render an image as it is loading but is not required to do so.

Attribute definitions:

x = "<coordinate>"
The x-axis coordinate of one corner of the rectangular region.
If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
y = "<coordinate>"
The y-axis coordinate of one corner of the rectangular region.
If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
width = "<length>"
The width of the rectangular region.
A negative value is unsupported. A value of zero disables rendering of the element. If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
height = "<length>"
The height of the rectangular region.
A negative value is unsupported. A value of zero disables rendering of the element. If the attribute is not specified, the effect is as if a value of "0" were specified.
Animatable: yes.
preserveAspectRatio = "[defer] <align> [<meet>]"
See attribute definition for description.
Animatable: yes.
xlink:href = "<XMLRI>"
An IRI Reference . An empty attribute value (xlink:href="") disables rendering of the element. If the attribute is not specified, the effect is as if an empty value ("") was specified.
Animatable: yes.
type = "<media/type>"
A hint about the expected Internet Media Type of the raster image. Implementations may choose to not fetch images of formats that they do not support. Note that if an Internet Media type returned by the server, the server metadata is authoritative over the type attribute. See TAG finding Authoritative Metadata, section 5 Metadata Hints in Specifications. For optimizing download time by requiring a particular content format authors are encouraged to use 'requiredFormats', instead of 'type'.
Animatable: no.
focusable = "true" | "false" | "auto"
See attribute definition for description.
Animatable: Yes
Navigation Attributes
See definition.

An example:

Conditional processing

Conditional processing overview

SVG contains a 'switch' element along with attributes 'requiredFeatures', 'requiredExtensions', 'systemLanguage', 'requiredFormats' and 'requiredFonts' to provide an ability to specify alternate viewing depending on the capabilities of a given SVG user agent or the user's language.

Attributes 'requiredFeatures', 'requiredExtensions', 'systemLanguage', 'requiredFormats' and 'requiredFonts' act as tests and return either true or false results. The 'switch' renders the first of its direct children for which all of these attributes test true. If the given attribute is not specified, then a true value is assumed.

Example systemLanguage below displays one of three text strings (in Welsh, Greek, or Spanish) if those are the users preferred languages. Otherwise, in this example, it displays nothing.

Similar to the 'display' property, conditional processing attributes only affect the direct rendering of elements and do not prevent elements from being successfully referenced by other elements (such as via a 'use'). The conditional processing attributes in the shadow tree are processed normally. Conditional properties do not effect evaluation of 'script' elements, whose logic is run independently of conditional properties of any ancestor 'switch' elements.

Furthermore, the following rules must be applied:

The 'switch' element

The 'switch' element evaluates the 'requiredFeatures', 'requiredExtensions', 'systemLanguage', 'requiredFormats' and 'requiredFonts' attributes on its direct child elements in document order, and then renders the first child for which all of these attributes evaluate to true. All other child elements of the 'switch' element will therefore not be rendered. If the first child element which evaluates to true is a container element then the entire subtree is rendered. The conditional processing of the 'switch' element applies only to the rendering tree; non-rendering child elements, such as the 'script' element, are not affected by 'switch'.

Note that the values of properties 'display' and 'visibility' have no effect on 'switch' element processing. In particular, setting 'display' to none on a child of a 'switch' element has no effect on the testing associated with 'switch' element processing.

Note also that regardless of their rendering status, child elements of the 'switch' element are still part of the DOM, and rules applying to the uniqueness of the 'id' attribute still apply. Additionally, elements which would not otherwise be rendered due to conditional processing can still be referenced by 'id' (e.g. in the 'use' element or as the <XMLRI> of a paint server), and will be rendered in that instantiation.

The element definition schema and content model for 'switch' are not defined here. It is defined in all the places it can occur.

For more information and an example, see Embedding foreign object types.

Attribute definitions:

requiredFeatures = "<list-of-strings>"
See attribute definition for description.
Animatable: no.
requiredExtensions = "<list-of-strings>"
See attribute definition for description.
Animatable: no.
systemLanguage = "<list-of-language-ids>"
See attribute definition for description.
Animatable: no.
requiredFormats = "<list-of-content-types>"
See attribute definition for description.
Animatable: no.
requiredFonts = "<list-of-strings>"
See attribute definition for description.
Animatable: no.
focusable = "true" | "false" | "auto"
See attribute definition for description.
Animatable: Yes
Navigation Attributes
See definition.

The 'requiredFeatures' attribute

Definition of 'requiredFeatures':

requiredFeatures = "<list-of-strings>"
The value is a list of feature strings, with the individual values separated by white space. Determines whether all of the named features are supported by the SVG user agent. Only feature strings defined in an existing version of the SVG specification at the time the document is authored (such as the current Feature String appendix) should be used, while third party extension features that are not part of an SVG standard should be indicated using the 'requiredExtensions' attribute instead. If all of the given features are supported, then the attribute evaluates to "true"; otherwise, the current element and its children are skipped and thus will not be rendered.
Animatable: no.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute requiredFeatures, the attribute returns "false".

'requiredFeatures' is often used in conjunction with the 'switch' element. If the 'requiredFeatures' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

The 'requiredExtensions' attribute

The 'requiredExtensions' attribute defines a list of required language extensions. Language extensions are capabilities within an SVG user agent that go beyond the feature set defined in this specification. Each extension is identified by a IRI Reference.

Definition of requiredExtensions:

requiredExtensions = "<list-of-strings>"
The value is a list of IRI References which identify the required extensions, with the individual values separated by white space. Determines whether all of the named extensions are supported by the user agent. If all of the given extensions are supported, then the attribute evaluates to "true"; otherwise, the current element and its children are skipped and thus will not be rendered.
Animatable: no.

If a given IRI Reference contains white space within itself, that white space must be escaped.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'requiredExtensions', the attribute returns "false".

'requiredExtensions' is often used in conjunction with the 'switch' element. If the 'requiredExtensions' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

The 'systemLanguage' attribute

Definition of 'systemLanguage':

systemLanguage = "<list-of-language-ids>"
The value is a comma-separated list of language names as defined in [RFC3066]
Animatable: no.

Evaluates to "true" if one of the languages indicated by user preferences exactly equals one of the languages given in the value of this parameter, or if one of the languages indicated by user preferences exactly equals a prefix of one of the languages given in the value of this parameter such that the first tag character following the prefix is "-".

Evaluates to "false" otherwise.

Note: This use of a prefix matching rule does not imply that language tags are assigned to languages in such a way that it is always true that if a user understands a language with a certain tag, then this user will also understand all languages with tags for which this tag is a prefix.

The prefix rule simply allows the use of prefix tags if this is the case.

Implementation note: When making the choice of linguistic preference available to the user, implementers should take into account the fact that users are not familiar with the details of language matching as described above, and should provide appropriate guidance. As an example, users may assume that on selecting "en-gb", they will be served any kind of English document if British English is not available. The user interface for setting user preferences should guide the user to add "en" to get the best matching behavior.

Multiple languages may be listed for content that is intended for multiple audiences. For example, content that is presented simultaneously in the original Maori and English versions, would call for:

<text systemLanguage="mi, en"><!-- content goes here --></text>

However, just because multiple languages are present within the object on which the 'systemLanguage' test attribute is placed, this does not mean that it is intended for multiple linguistic audiences. An example would be a beginner's language primer, such as "A First Lesson in Latin," which is clearly intended to be used by an English-literate audience. In this case, the 'systemLanguage' test attribute should only include "en".

Authoring note: Authors should realize that if several alternative language objects are enclosed in a 'switch', and none of them matches, this may lead to situations where no content is displayed. It is thus recommended to include a "catch-all" choice at the end of such a 'switch' which is acceptable in all cases.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'systemLanguage', the attribute returns "false".

'systemLanguage' is often used in conjunction with the 'switch' element. If the 'systemLanguage' attribute is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

The 'requiredFormats' attribute

Many resources, especially media such as audio and video, have a wide range of formats. As it is often not possible to require support for a particular format, due to legal or platform restrictions, it is often necessary for content to provide alternatives so that SVG user agents can choose the format they support.

The 'requiredFormats' attribute is a generic conditional processing attribute that can be used to enable or disable particular branches in the SVG document. It defines a list of resource formats. The SVG user agent must support all of the resource types for the attribute to evaluate to "true".

Definition of 'requiredFormats':

requiredFormats = "<list-of-content-types>"
The value is a list of Internet Media types, with the individual values separated by white space. For a list of Internet Media types (formerly called MIME types), see the IANA Media Type registry For a list of MIME types for audio/video codecs, see the IANA codec registry and RFC2361.
The following 'requiredFormats' must always evaluate to "true" in compliant SVG viewers:
  • image/png
  • image/jpeg
  • image/svg+xml

Animatable: no.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'requiredFormats', the attribute returns "false". Format definitions that are not understood by the SVG user agent return "false".

'requiredFormats' is often used in conjunction with the 'switch' element. If the 'requiredFormats' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

The 'requiredFonts' attribute

If the author wishes to have complete control over the appearance and location of text in the document then they must ensure that the correct font is used when rendering the text. This can be achieved by using SVG Fonts and embedding the font in the document. However, this is not practical in all cases, especially when the number of glyphs used is very large or if the licensing of the font forbids such embedding.

Definition of 'requiredFonts':

requiredFonts = "<list-of-family-names>"
The 'requiredFonts' attribute is a generic conditional processing attribute that can be used to enable or disable particular branches in the SVG document. It defines a list of fonts, separated by commas. The SVG user agent must have access to all of the fonts, either installed on the system or as an SVG font defined or embedded within the document, for the attribute to evaluate to "true". 'requiredFonts' uses same syntax as the 'font-family' property, for example when processing quoted strings, multiple, leading and trailing spaces, and case sensitivity.
Animatable: no.

If the attribute is not present, then its implicit return value is "true". If a null string or empty string value is given to attribute 'requiredFonts', the attribute returns "false".

'requiredFonts' is often used in conjunction with the 'switch' element. If the 'requiredFonts' is used in other situations, then it represents a simple switch on the given element whether to render the element or not.

External resources

The 'externalResourcesRequired' attribute

Documents often reference and use the contents of other document and other web resources as part of their rendering or processing. In some cases, authors want to specify that particular resources are required for a document to be considered correct.

Attribute 'externalResourcesRequired' is available on all container elements except 'defs' and on all elements which potentially can reference external resources. It specifies whether referenced resources that are not part of the current document are required for proper rendering of the given element.

Attribute definition:

externalResourcesRequired = "false" | "true"
false
(The lacuna value.) Indicates that resources external to the current document are optional. Document rendering can proceed even if external resources are unavailable to the current element and its descendants.
true
Indicates that resources external to the current document are required. If an external resource is not available (for example the request for the required resource times out), progressive rendering is suspended, the load event is not fired for the element, and the document goes into an error state (see Error processing). The document remains in an error state until all required resources become available.

Attribute 'externalResourcesRequired' is not inheritable (from a sense of attribute value inheritance), but if set on a container element, its value will apply to all elements within the container.

Because setting externalResourcesRequired="true" on a container element will the effect of disabling progressive display of the contents of that container, if that container includes elements that reference external resources, tools that generate SVG content should normally not just set externalResourcesRequired="true" on the 'svg' element on a universal basis. Instead, it is better to specify externalResourcesRequired="true" on those particular elements which specifically need the availability of external resources in order to render properly.

For externalResourcesRequired: Animatable: no.

Progressive rendering

When progressively downloading a document, an SVG user agent conceptually builds a tree of nodes in various states. The possible states for these nodes are unresolved, resolved and error.

This description uses two conceptual parsing events to simplify the prose in explaining the intended behaviour of progressive rendering. The events referred to in the following prose are the start element and end element events. The start element event is considered to be triggered when a Start-Tag or an Empty-Element Tag is read. The end element event occurs either immediately following the start element event in the case of an Empty-Element Tag, or when an End-Tag is read. The terms Start-Tag, End-Tag and Empty-Element Tag are as defined in the XML specification (either XML 1.0 [XML10] or XML 1.1 [XML11]).

When loading a document following the start element event on a node, that node becomes part of the document tree in the unresolved state. If the node's dependencies are successfully resolved, then the node enters the resolved state or if the node's dependencies are found to be in error, then the node enters the error state.

Node dependencies include both children content (like the child elements on a 'g') and resources (e.g. images referenced by an 'image') referenced from that node or from its children. Empty elements (elements without children) become resolved when the end element event occurs on the element; elements with child nodes become resolved when all their children are resolved and when the end element event occurs on the element. Resources become resolved (or found in error) by an SVG user agent specific mechanism.

SVG user agents must implement progressive rendering although there is no minimum rendering update frequency required for conformance. Implementations should find their own balance between processing the changes in the document tree and rendering the tree to produce a smooth rendering avoiding significant pauses. The following rules apply to progressive rendering:

  • The SVG user agent has the opportunity to update the rendering following each start element and/or end element event, i.e. each time the SVG user agent parses a Start-Tag, Empty-Element Tag or End-Tag.
  • The SVG user agent renders the conceptual document tree nodes in document order up to, and not including the first node in the 'unresolved' state which has 'externalResourcesRequired' set to true. Nodes in the 'resolved' state are always rendered. Nodes in the unresolved state but with 'externalResourcesRequired' set to false are rendered in their current state. If the node has no rendering (e.g, an 'image' pending a resource), then nothing is rendered for that node.
  • If a node enters the error state then the document enters the error state and progressive rendering stops.

Note that even if the SVG user agent has the opportunity to update the rendering after each start/end element event there are situations where such an update shouldn't be done. E.g. 'font' element children ('font-face', 'hkern', 'missing-glyph', 'glyph') should not cause an update of the document rendering, only the end element event on the 'font' element should cause a document rendering as for other node types.

Note that forward referencing from a 'discard' element should be avoided when using progressive rendering. If it fails to find (and thus discard) an element, it will not later discard the element when it has finally loaded.

Example

In this example, the 'g' element rendering may start when the 'g' End-Tag has been parsed and processed and when all the resources needed by its children have been resolved. This means that the group's rendering may start when the group has been fully parsed and myImage.png has been successfully retrieved.

Forward reference of use element

In this example, the various renderings may be (the rendering state follows the colon):

  1. 'use'start element: empty
  2. 'circle'start element: yellow circle
  3. 'g'start element: no update
  4. 'rect'start element (use reference becomes resolved): green rect, yellow circle, red rect

Forward reference on 'use' with externalResourcesRequired="true"

  1. 'use'start element: empty
  2. 'circle'start element: empty 'use' is unresolved, externalResourcesRequired="true", rendering is stopped at the 'use')
  3. 'g'start element: no update
  4. g.myGroupstart element: no update (use is resolved but externalResourcesRequired="true" so rendering may not proceed until that reference enters the resolved state)
  5. 'rect'start element: no update
  6. 'use'start element: no update
  7. g.myGroupend element (#myGroup reference becomes resolved, rendering can proceed): green rect, purple rect, yellow circle, red rect, purple rect.

Forward reference with 'use' to an element under a container with externalResourcesRequired="true"

  1. 'use'start element: empty
  2. pink.circlestart element: pink circle
  3. 'g'start element: no update (rendering is suspended because of externalResourcesRequired="true" on the 'g' element, i.e. because the children of 'g' are not resolved at the time of parsing of the start tag of 'g').
  4. yellow.circlestart element: no update (rendering suspended because of 'g')
  5. myRect.rectstart element: no update
  6. 'g'end element. Resources referenced by 'use' become resolved and can be rendered. Rendering can proceed: green rect, pink circle, yellow circle, red rect

Font Resolution Example

Progressive rendering:

  1. 'text'start element: 'A' rendered with the default font
  2. 'defs'start element: no update
  3. fontA.fontstart element: no update
  4. fontA.font-facestart element: no update
  5. fontA.missingGlyphstart element: no update
  6. fontA.glyphAstart element: no update
  7. fontA.fontend element: 'A' rendered with fontA (represents current document state rendering)
  8. fontB.fontstart element: no update
  9. fontB.font-facestart element: no update
  10. fontB.missingGlyphstart element: no update
  11. fontB.glyphAstart element: no update
  12. fontB.fontend element: 'A' rendered with fontB (represents current document state rendering)
  13. fontC.fontstart element: no update
  14. fontC.font-facestart element: no update
  15. fontC.missingGlyphstart element: no update
  16. fontC.glyphAstart element:
  17. fontC.fontend element: 'A' rendered with fontC (represents current document state rendering)

The 'prefetch' element

SVG 1.1 did not specify when an SVG user agent should begin download referenced media. This lead to implementation differences particularly when the media was not used in the initial document state (e.g. it was offscreen or hidden). SVG 1.2 does not require SVG user agents to download referenced media that is not visual at the time the document is loaded, unless those media are contained inside a subtree for which 'externalResourcesRequired' is set to true. This means there may be a pause to download the file the first time a piece of media is displayed. More advanced SVG user agents may wish to predict that particular media streams will be needed and therefore download them in anticipation.

SVG 1.2 therefore adds functionality to allow content developers to suggest prefetching content from the server before it is needed to improve the rendering performance of the document. The 'prefetch' element has been reused from Section 4.4 of SMIL 2.1 (The PrefetchControl Module) with the following modifications:

The 'prefetch' element will give a suggestion or hint to a SVG user agent that media will be used in the future and the author would like part or all of it fetched ahead of time to make the document playback smoother. As it is a hint, user-agents may ignore 'prefetch' elements, though doing so may cause an interruption in the document playback when the resource is needed. It gives authoring tools and authors the ability to schedule retrieval of resources when they think that there is available bandwidth or time to do it.

When instead of referring to external media, 'prefetch' refers to the same document it occurs in, then it can only reference a top level 'g' element. A 'top level' 'g' element is a 'g' element that is a direct child of the 'svg' element.

To enable smooth playback during progressive downloading in this scenario, it is recommended that each adjacent top level 'g' element contain adjacent chronological scenes in the animation. In this case the 'prefetch' element must appear in a 'defs' block before all defined 'g' elements in the document. In such cases, 'prefetch' is used to tell the SVG user agent how much it needs to buffer in order to be able to play content back in a smooth and predictable manner.

Attribute definitions:

mediaSize = "<long>"
Defines how much of the media to fetch in bytes as a function of the file size of the media.
When 'prefetch' refers to a resource in the same document (i.e. a top level 'g' element), the mediaSize attribute indicates the size in bytes of the 'g' element and its children. That size corresponds to the encodings used when transmitting the document. If the document is encoded in UTF-8 [RFC 3629]and gzipped, then the size of the gzipped UTF-8 fragment applies. If that same document were decompressed and transcoded to UTF-16 [RFC 2781] the hints will become stale. Since streaming hints are to be used primarily in streaming scenarios, it is not expected that hint staleness will occur frequently.
Animatable: no.
mediaTime = "<clock-value>"
Defines how much of the media to fetch as a function of the duration of the media. For discrete media (non-time based media like image/png) using this attribute causes the entire resource to be fetched.
When 'prefetch' refers to a resource in the same document (i.e. a top level 'g' element), this is the active duration of the referenced element. In cases where the exact active duration can not be calculated before hand (e.g. end of an animation depends on user interaction), it is suggested that the content author estimate the minimum active duration for the referenced element. This estimate, even if zero, will allow the SVG user agent to calculate how much of the overall document to download before beginning playback in a streaming scenario.
Animatable: no.
bandwidth = "<long>"
Defines how much network bandwidth, in bits per second, the SVG user agent should use when doing the prefetch. If the attribute is not specified, all available bandwidth should be used.
Animatable: no.
mediaCharacterEncoding = "<string>"
Indicates the XML character set encoding (UTF-8, ISO-8859-1, etc.) that the 'mediaSize' attribute applies to. Tools that produce SVG should include this attribute if they specify the 'mediaSize' attribute. The main use of this attribute is to know what character encoding was used when measuring 'mediaSize' so that staleness of the hints may be easily detected. If the attribute is not specified, the encoding that was used to calculate the size is that which is returned by the server.
Animatable: no.
mediaContentEncodings = "<list-of-strings>"
The 'mediaContentEncodings' attribute is a white space separated list of the content encodings as defined in section 3.5 of [HTTP/1.1] (gzip, compress, etc.) that the 'mediaSize' attribute applies to. The order of the list is the order in which the content encodings were applied to encode the data. Note that while situations in which multiple content codings are applied are currently rare, they are allowed by HTTP/1.1 and thus that functionality is supported by SVG. Tools that produce SVG must include this attribute if they specify the 'mediaSize' attribute and the Content-Encoding is other than the identity encoding. The main use of this attribute is to know what parameters were used when measuring 'mediaSize' so that staleness of the hints may be easily detected. If the 'mediaContentEncodings' attribute is not specified it is as if the 'identity' encoding value from HTTP/1.1 has been specified. This indicates that no transformation (i.e. encodings) at all has been used.
Animatable: no.
xlink:href = "<XMLRI>"
An IRI reference to the resource to prefetch. An empty attribute value (xlink:href="") means that no prefetching will occur. If the attribute is not specified, the effect is as if an empty value ("") was specified.
Animatable: no.

When 'prefetch' refers to external media, if both 'mediaSize' and 'mediaTime' are specified, then 'mediaSize' shall be used and 'mediaTime' is ignored. If neither 'mediaSize' nor 'mediaTime' is specified, the behavior is that the entire media should be fetched.

When 'prefetch' refers to a resource in the same document (i.e. a top level 'g' element), both the 'mediaSize' and 'mediaTime' attributes can be used together by a more advanced SVG user agent to determine how much it needs to buffer in order to be able to play content back in a smooth manner.

Below is an example of the 'prefetch' element when it refers to external media:

Below is an example of the 'prefetch' element when it refers to a resource (i.e. a top level 'g' element in the same document):

Common attributes

Attributes common to all elements: 'class', 'role', 'id', 'xml:id' and 'xml:base'

The 'class', 'id', 'xml:id' and 'xml:base' attributes are available on all elements required by SVG Tiny 1.2:

Attribute definitions:

class = <XML-NMTOKENS>
This attribute indicates membership in one or more sets. Any number of elements may be assigned to the same set. Multiple set names must be separated by white space characters.
Animatable: yes.
role = <XML-NMTOKENS>
This attribute indicates membership in one or more sets. Any number of elements may be assigned to the same set. Multiple set names must be separated by white space characters.
Animatable: yes.
id = <ID>
XML attribute for assigning a unique name to an element. Refer to the "xml:id Version 1.0" Recommendation [XMLID]. It is recommended that new content should use 'xml:id' instead.
Animatable: no.
xml:id = <ID>
Standard XML attribute for assigning a unique name to an element. Refer to the "xml:id Version 1.0" [xml:id]. Recommended for new content.
Animatable: no.
xml:base = "<XMLRI>"
Specifies a base IRI other than the base IRI of the document or external entity. Refer to the "XML Base" specification [XML-BASE].
Animatable: no.

The 'class' attribute

The class attribute assigns one or more class names to an element. The element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles:

  • As a style sheet selector (when an author wishes to assign style information to a set of elements). Note: SVG Tiny 1.2 does not mandate the support of style sheets.
  • For general purpose processing by user agents.

The 'role' attribute

The role attribute assigns one or more role values to an element. The element may be said to have these roles. A role value may be shared by several element instances. Unlike the class attribute, role attribute values are intended to be selected from a predefined set of values with specific semantic aspects that are assigned to the element, such as those defined in the ARIA ontology and with future SVG specifications.

The role attribute is intended to functionally align with the XHTML Role Attribute Module.

The 'id' and 'xml:id' attributes

It is strongly recommended that SVG Generators only use 'xml:id' to assign identity to elements. For backwards compatibility purposes, one may also specify the 'id' attribute but such an approach is not without issues:

  • it is expected that the 'id' attribute will be deprecated in a future version of this specification, and therefore that SVG Generators should transition to using 'xml:id' only as early as possible;
  • there remains only one single id field on the SVGElement interface, therefore when it is updated both attributes must be updated too as a consequence;
  • consequently, since SVGElement::id is updated when one of the attribute values is modified (e.g. using the setAttributeNS(), setTraitNS(), or setTrait() methods), the other attribute must be set to the same value;
  • when both 'id' and 'xml:id' are specified on the same element but with different values, the SVGElement::id field must return either of the values but should give precedence to the 'xml:id' attribute.
  • when both 'id' and 'xml:id' are specified on the same element, implementation should not consider the 'id' attribute to be of type ID.

The 'xml:lang' and 'xml:space' attributes

Elements that might contain character data content have attributes 'xml:lang' and 'xml:space':

Attribute definitions:

xml:lang = "<language-id>"
Standard XML attribute to specify the language (e.g., English) used in the contents and attribute values of particular elements. The value is either a language tag as defined in IETF Best Current Practice 47 [BCP 47] or the empty string, "". Refer to the "Extensible Markup Language (XML) 1.0 (Third Edition)" Recommendation [XML10] and "Extensible Markup Language (XML) 1.1" Recommendation [XML11].
Animatable: no.
xml:space = "default" | "preserve"
Standard XML attribute to specify whether white space is preserved in character data. The only possible values are default and preserve. Refer to the "Extensible Markup Language (XML) 1.0 (Third Edition)" Recommendation [XML10] and "Extensible Markup Language (XML) 1.1" Recommendation [XML11] and to the discussion White space handling in SVG.
Animatable: no.