Linking – SVG 1.1 (Second Edition)
SVG 1.1 (Second Edition) – 16 August 2011
Top
Contents
Previous
Next
Elements
Attributes
Properties
17 Linking
Contents
17.1 References
17.1.1 Overview
17.1.2 IRIs and URIs
17.1.3 Syntactic forms: IRI and FuncIRI
17.1.4 Processing of IRI references
17.1.5 IRI reference attributes
17.2 Links out of SVG content: the
‘a’
element
17.3 Linking into SVG content: IRI fragments and SVG views
17.3.1 Introduction: IRI fragments and SVG views
17.3.2 SVG fragment identifiers
17.3.3 Predefined views: the
‘view’
element
17.3.4 Highlighting views
17.4 DOM interfaces
17.4.1 Interface SVGAElement
17.4.2 Interface SVGViewElement
17.1 References
17.1.1 Overview
On the Internet, resources are identified using
IRI
(Internationalized Resource Identifiers). For
example, an SVG file called someDrawing.svg located at
IRI
An
IRI
can also address a particular element within an XML
document by including an
IRI
fragment
identifier as part of the
IRI
. An
IRI
which includes an
IRI
fragment identifier consists of an optional base
IRI
, followed by a "#" character,
followed by the
IRI
fragment identifier. For example, the
following
IRI
can be used to specify the element whose ID is
"Lamppost" within file someDrawing.svg:
17.1.2 IRIs and URIs
Internationalized
Resource Identifiers (
IRI
s) are a more generalized complement to Uniform Resource
Identifiers (URIs). An
IRI
is a sequence of characters from the
Universal Character Set [
UNICODE
]. A URI is constructed from a much
more restricted set of characters. All URIs are already conformant
IRI
s. A mapping from
IRI
s to
URIs is defined by the
IRI
specification, which means that IRIs can be used instead of URIs
in XML documents, to identify resources.
IRI
s can be converted to URIs for resolution
on a network, if the protocol does not support
IRI
s directly.
Previous versions of SVG, following XLink, defined an IRI reference type
as a URI
or as a sequence of characters which must result in an IRI after a
particular escaping procedure was applied
. The escaping procedure was repeated in the
XLink 1.0 specification [
XLINK
], and in the W3C
XML Schema Part 2: Datatypes specification [
SCHEMA2
]. This copying introduced the
possibility of error and divergence, but was done because the
IRI
specification was not
yet standardized.
In this specification, the correct term
IRI
is used for this "URI or sequence of characters
plus an algorithm" and the escaping method, which turns IRIs into URIs, is defined by reference to the
IRI
specification
RFC3987
], which
has since become an IETF Proposed Standard. Other W3C
specifications are expected to be revised over time to remove these duplicate
descriptions of the escaping procedure and to refer to
IRI
directly.
17.1.3 Syntactic forms: IRI and FuncIRI
IRIs are used in the
‘xlink:href’
attribute. Some attributes allow both IRIs and text strings as content. To disambiguate a text string from a relative IRI, the functional notation

is used. This is simply an IRI delimited with a functional notation.
Note:
For historical reasons, the delimiters are "url(" and ")", for compatibility with the CSS specifications. The FuncIRI form is used in
presentation attributes
SVG makes extensive use of
IRI
references, both absolute and relative, to other
objects. For example, to
fill
a rectangle with a linear
gradient, you first define a
‘linearGradient’
element and give
it an ID, as in:
...
You then reference the linear gradient as the value of the
‘fill’
property for the rectangle, as in the following example:

SVG supports two types of IRI references:
local IRI references
, where the IRI reference does not contain an

or

and thus only contains
a fragment identifier (i.e.,
#
or
#xpointer(id
))
non-local IRI references
, where the IRI reference does contain an

or

17.1.4 Processing of IRI references
The following rules apply to the processing of IRI references:
IRI references to nodes that do not exist shall be treated as
invalid references.
IRI references to elements which are inappropriate
targets for the given reference shall be treated as invalid
references (see list below for appropriate targets). For
example, the
‘clip-path’
property can only refer to
‘clipPath’
elements. The property setting
clip-path:url(#MyElement)
is an
invalid reference if the referenced element is not a
‘clipPath’
IRI references that directly or indirectly reference
themselves are treated as invalid circular references.
The following list describes the elements and properties that allow IRI
references and the valid target types for those references:
the
‘a’
element can reference any local or non-local resource
the
‘altGlyph’
element must reference either an
‘altGlyphDef’
element or a
‘glyph’
element
the
‘animate’
element (see
Identifying the target element for an animation
for reference rules)
the
‘animateColor’
element (see
Identifying the target element for an animation
for reference rules)
the
‘animateMotion’
element (see
Identifying the target element for an animation
for reference rules)
the
‘animateTransform’
element (see
Identifying the target element for an animation
for reference rules)
the
‘clip-path’
property must reference a
‘clipPath’
element
the
‘color-profile’
element must reference an ICC profile resource
the
‘color-profile’
property must reference an ICC profile resource or a
‘color-profile’
element
the
'src'
descriptor on an @color-profile definition must reference an ICC profile resource or a
‘color-profile’
element
the
‘cursor’
element must reference a resource that can provide an image for the cursor graphic
the
‘cursor’
property must reference a resource that can provide an image for the cursor graphic
the
‘feImage’
element must reference any local or non-local resource
the
‘fill’
property (see
Specifying paint
for reference rules)
the
‘filter’
element must reference a
‘filter’
element
the
‘filter’
property must reference a
‘filter’
element
the
‘image’
element must reference any local or non-local resource
the
‘linearGradient’
element must reference a
‘linearGradient’
or
‘radialGradient’
element
the
‘marker’
‘marker-start’
‘marker-mid’
and
‘marker-end’
properties must reference a
‘marker’
element.
the
‘mask’
property must reference a
‘mask’
element
the
‘pattern’
element must reference a
‘pattern’
element
the
‘radialGradient’
element must reference a
‘linearGradient’
or
‘radialGradient’
element
the
‘script’
element must reference an external resource that provides the script content
the
‘stroke’
property (see
Specifying paint
for reference rules)
the
‘textPath’
element must reference a
‘path’
element
the
‘tref’
element can reference any SVG element
the
‘set’
element (see
Identifying the target element for an animation
for reference rules)
the
‘use’
element can reference any local or non-local resource
The following rules apply to the processing of invalid IRI references:
An invalid local IRI reference (i.e., an invalid references to a node
within the current document) represents an error (see
Error processing
), apart from the
‘xlink:href’
attribute on the
‘a’
element and the properties
that allow for backup values in the case where the IRI reference is invalid
(see
‘fill’
and
‘stroke’
).
An invalid circular IRI reference represents an error (see
Error processing
).
When attribute
‘externalResourcesRequired’
has been set to
'true'
on the referencing element or one of
its ancestors, then an unresolved external IRI reference (i.e., a resource
that cannot be located) represents an error (see
Error processing
).
17.1.5 IRI reference attributes
IRI
references are normally specified with an
‘href’
attribute in the XLink [
XLink
] namespace. For example,
if the
prefix of 'xlink' is used for attributes in the XLink
namespace, then the attribute is be specified as
‘xlink:href’
. The value of this
attribute forms a reference for the desired resource (or
secondary resource, if there is a fragment identifier).
The value of the
‘href’
attribute must be an
Internationalized Resource Identifier
If the protocol, such as HTTP, does not support
IRI
s directly,
the
IRI
is converted to a URI by the SVG implementation, as described
in section 3.1 of the
IRI specification
RFC3987
Because it is impractical for any application to check that
a value is an
IRI
reference, this specification follows the lead
of the
IRI Specification
in this matter and imposes no such conformance testing
requirement on SVG applications.
If the
IRI
reference is relative, its absolute version must be computed by the method described in
XML Base
before use [
XML-BASE
].
xlink:type
= "
simple
Identifies the type of XLink being used. In SVG 1.1, only
simple links are available.
Links are simple links by default,
so the attribute
xlink:type="simple"
is optional and may be omitted on simple links.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:role
= "

An optional
IRI
reference that identifies some resource that describes
the intended property. The value must be an
IRI
reference as
defined in [
RFC3987
],
except that if the
IRI
scheme used is allowed to have
absolute and relative forms, the
IRI
portion must be
absolute. When no value is supplied, no particular role
value shall be inferred.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:arcrole
= "

An optional
IRI
reference that identifies some resource that describes
the intended property. The value must be an
IRI
reference as
defined in [
RFC3987
],
except that if the
IRI
scheme used is allowed to have
absolute and relative forms, the
IRI
portion must be
absolute. When no value is supplied, no particular role
value shall be inferred. The arcrole
attribute corresponds to the [
RDF-PRIMER
] notion
of a property, where the role can be interpreted as stating
that "starting-resource HAS arc-role ending-resource." This
contextual role can differ from the meaning of an ending
resource when taken outside the context of this particular
arc. For example, a resource might generically represent a
"person," but in the context of a particular arc it might
have the role of "mother" and in the context of a different
arc it might have the role of "daughter."
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:title
= "

The title attribute shall be used to describe the meaning of
a link or resource in a human-readable fashion, along the
same lines as the role or arcrole attribute. A value is
optional; if a value is supplied, it shall contain a
string that describes the resource. In general it is preferable
to use a
‘title’
child element
rather than a
‘title’
attribute. The use of this
information is highly dependent on the type of processing
being done. It may be used, for example, to make titles
available to applications used by visually impaired users,
or to create a table of links, or to present help text that
appears when a user lets a mouse pointer hover over a
starting resource.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:show
= "
new
' |
replace
' |
embed
' |
other
' |
none
This attribute is provided for backwards compatibility with SVG
1.1. It provides documentation to XLink-aware processors. In
case of a conflict, the target attribute has priority, since it can
express a wider range of values.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:actuate
= "
onLoad
This attribute is provided for backwards compatibility with SVG
1.1. It provides documentation to XLink-aware processors.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
In all cases, for compliance with either the "Namespaces in XML 1.0" or the "Namespaces in XML 1.1"
Recommendation [
XML-NS10
][
XML-NS
], an
explicit XLink namespace declaration must be provided whenever
one of the above XLink attributes is used within SVG content.
One simple way to provide such an XLink namespace declaration
is to include an
‘xmlns’
attribute
for the XLink namespace on the
‘svg’
element for content that uses
XLink attributes. For example:



17.2 Links out of SVG content: the
‘a’
element
SVG provides an
‘a’
element, to indicate links (also known
as
hyperlinks
or
Web links
). The
‘a’
element may
contain any element that its parent may contain, except itself.
SVG uses XLink ([
XLink
])
for all link definitions. SVG 1.1 only requires
that user agents support XLink's notion of
simple links
. Each simple link associates exactly two resources, one
local and one remote, with an arc going from the former to the latter.
A simple link is defined for each separate rendered element contained
within the
‘a’
element; thus, if the
‘a’
element contains
three
‘circle’
elements, a link is created for each circle. For
each rendered element within an
‘a’
element, the given rendered
element is the local resource (the source anchor for the link).
The remote resource (the destination for the link) is defined by
IRI
specified by the XLink
‘xlink:href’
attribute on the
‘a’
element. The remote resource
may be any Web resource (e.g., an image, a video clip, a sound bite, a
program, another SVG document, an HTML document, an element within the
current document, an element within a different document, etc.). By
activating these links (by clicking with the mouse, through keyboard
input, voice commands, etc.), users may visit these resources.
Example link01
assigns
a link to an ellipse.

"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
Example link01 - a link on an ellipse

fill="none" stroke="blue" stroke-width=".03"/>

fill="red" />


Example link01
View this example as SVG (SVG-enabled browsers only)
If the above SVG file is viewed by a user agent that supports both
SVG and HTML, then clicking on the ellipse will cause the current window
or frame to be replaced by the W3C home page.
‘a’
Categories:
Container element
Content model:
Any number of the following elements, in any order:
animation elements
‘animate’
‘animateColor’
‘animateMotion’
‘animateTransform’
‘set’
descriptive elements
‘desc’
‘metadata’
‘title’
shape elements
‘circle’
‘ellipse’
‘line’
‘path’
‘polygon’
‘polyline’
‘rect’
structural elements
‘defs’
‘g’
‘svg’
‘symbol’
‘use’
gradient elements
‘linearGradient’
‘radialGradient’
‘a’
‘altGlyphDef’
‘clipPath’
‘color-profile’
‘cursor’
‘filter’
‘font’
‘font-face’
‘foreignObject’
‘image’
‘marker’
‘mask’
‘pattern’
‘script’
‘style’
‘switch’
‘text’
‘view’
Attributes:
conditional processing attributes
‘requiredFeatures’
‘requiredExtensions’
‘systemLanguage’
core attributes
‘id’
‘xml:base’
‘xml:lang’
‘xml:space’
graphical event attributes
‘onfocusin’
‘onfocusout’
‘onactivate’
‘onclick’
‘onmousedown’
‘onmouseup’
‘onmouseover’
‘onmousemove’
‘onmouseout’
‘onload’
presentation attributes
‘alignment-baseline’
‘baseline-shift’
‘clip’
‘clip-path’
‘clip-rule’
‘color’
‘color-interpolation’
‘color-interpolation-filters’
‘color-profile’
‘color-rendering’
‘cursor’
‘direction’
‘display’
‘dominant-baseline’
‘enable-background’
‘fill’
‘fill-opacity’
‘fill-rule’
‘filter’
‘flood-color’
‘flood-opacity’
‘font-family’
‘font-size’
‘font-size-adjust’
‘font-stretch’
‘font-style’
‘font-variant’
‘font-weight’
‘glyph-orientation-horizontal’
‘glyph-orientation-vertical’
‘image-rendering’
‘kerning’
‘letter-spacing’
‘lighting-color’
‘marker-end’
‘marker-mid’
‘marker-start’
‘mask’
‘opacity’
‘overflow’
‘pointer-events’
‘shape-rendering’
‘stop-color’
‘stop-opacity’
‘stroke’
‘stroke-dasharray’
‘stroke-dashoffset’
‘stroke-linecap’
‘stroke-linejoin’
‘stroke-miterlimit’
‘stroke-opacity’
‘stroke-width’
‘text-anchor’
‘text-decoration’
‘text-rendering’
‘unicode-bidi’
‘visibility’
‘word-spacing’
‘writing-mode’
xlink attributes
‘xlink:href’
‘xlink:show’
‘xlink:actuate’
‘xlink:type’
‘xlink:role’
‘xlink:arcrole’
‘xlink:title’
‘class’
‘style’
‘externalResourcesRequired’
‘transform’
‘xlink:href’
‘xlink:show’
‘xlink:actuate’
‘target’
DOM Interfaces:
SVGAElement
Attribute definitions:
xlink:show
= "
new
" |
replace
This attribute provides documentation to XLink-aware processors. If
target="_blank"
then use
xlink:show="new"
else use
'replace'
. In
case of a conflict, the target attribute has priority, since it can
express a wider range of values.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:actuate
"onRequest"
This attribute provides documentation to XLink-aware processors that
an application should traverse from the starting
resource to the ending resource only on a post-loading
event triggered for the purpose of traversal.
Refer to the
XML Linking Language (XLink)
XLINK
].
Animatable
no.
xlink:href
= "

The location of the referenced object, expressed as an
IRI reference
Animatable
: yes.
target
= "
_replace
" |
_self
" |
_parent
" |
_top
" |
_blank
" |

This attribute should be used when there are multiple possible targets for
the ending resource, such as when the parent document is a
multi-frame HTML or XHTML document. This attribute specifies the
name or portion of the target window, frame, pane, tab, or other
relevant presentation context (e.g., an HTML or XHTML frame, iframe, or object element) into
which a document is to be opened when the link is activated:
_replace
The current SVG image is replaced by the linked content in the
same rectangular area in the same frame as the current SVG image.
_self
The current SVG image is replaced by the linked content in the
same frame as the current SVG image. If the attribute is not specified,
'_self'
is assumed.
_parent
The immediate frameset parent of the SVG image is replaced by the
linked content.
_top
The content of the full window or tab, including any frames, is
replaced by the linked content
_blank
A new un-named window or tab is requested for the display of the
linked content. If this fails, the result is the same as
_top

Specifies the name of the frame, pane, or other relevant
presentation context for display of the linked content. If this
already exists, it is re-used, replacing the existing content. If
it does not exist, it is created (the same as
'_blank'
, except that
it now has a name).
Note: The value
'_new'
is
not
a legal value for target (use
'_blank'
).
Animatable
yes.
17.3 Linking into SVG content: IRI fragments and SVG views
17.3.1 Introduction: IRI fragments and SVG views
Because SVG content often represents a picture or drawing
of something, a common need is to link into a particular
view
of the document, where a view indicates
the initial transformations so as to present a closeup of a particular
section of the document.
17.3.2 SVG fragment identifiers
To link into a particular view of an SVG document, the IRI fragment
identifier needs to be a correctly formed
SVG
fragment identifier
. An SVG fragment identifier defines the
meaning of the "selector" or "fragment identifier" portion of IRIs that
locate resources of MIME media type "image/svg+xml".
An SVG fragment identifier can come in two forms:
Shorthand
bare name
form of addressing (e.g.,
MyDrawing.svg#MyView
). This form of
addressing, which allows addressing an SVG element by its ID, is compatible
with the fragment addressing mechanism for older versions of HTML.
SVG view specification
(e.g.,
MyDrawing.svg#svgView(viewBox(0,200,1000,1000))
).
This form of addressing specifies the desired view of the
document (e.g., the region of the document to view, the
initial zoom level) completely within the SVG fragment
specification. The contents of the SVG view specification are
the five parameter specifications,
viewBox(...)
preserveAspectRatio(...)
transform(...)
zoomAndPan(...)
and
viewTarget(...)
, whose parameters have the
same meaning as the corresponding attributes on a
‘view’
element, or,
in the case of
transform(...)
, the same
meaning as the corresponding attribute has on a
‘g’
element).
An SVG fragment identifier is defined as follows:
SVGFragmentIdentifier ::= BareName |
SVGViewSpec

BareName ::= XML_Name
SVGViewSpec ::= 'svgView(' SVGViewAttributes ')'
SVGViewAttributes ::= SVGViewAttribute |
SVGViewAttribute ';' SVGViewAttributes

SVGViewAttribute ::= viewBoxSpec |
preserveAspectRatioSpec |
transformSpec |
zoomAndPanSpec |
viewTargetSpec
viewBoxSpec ::= 'viewBox(' ViewBoxParams ')'
preserveAspectRatioSpec = 'preserveAspectRatio(' AspectParams ')'
transformSpec ::= 'transform(' TransformParams ')'
zoomAndPanSpec ::= 'zoomAndPan(' ZoomAndPanParams ')'
viewTargetSpec ::= 'viewTarget(' ViewTargetParams ')'
where:
ViewBoxParams
corresponds to the
parameter values for the
‘viewBox’
attribute on the
‘view’
element. For example,
viewBox(0,0,200,200)
AspectParams
corresponds to the
parameter values for the
‘preserveAspectRatio’
attribute on the
‘view’
element. For example,
preserveAspectRatio(xMidYMid)
TransformParams
corresponds to the
parameter values for the
‘transform’
attribute that is available on
many elements. For example,
transform(scale(5))
ZoomAndPanParams
corresponds to the
parameter values for the
‘zoomAndPan’
attribute on the
‘view’
element. For example,
zoomAndPan(magnify)
ViewTargetParams
corresponds to the
parameter values for the
‘viewTarget’
attribute on the
‘view’
element. For example,
viewTarget(MyElementID)
Spaces are not allowed in fragment specifications; thus, commas
are used to separate numeric values within an SVG view specification
(e.g.,
#svgView(viewBox(0,0,200,200))
and semicolons are used to separate attributes (e.g.,
#svgView(viewBox(0,0,200,200);preserveAspectRatio(none))
).
Semicolons used to separate 'SVGViewAttribute' in SVG fragments may be url-escaped (as %3B);
this is useful when animating a (semi-colon separated)
list of IRIs because otherwise the semicolon would be interpreted as a list separator.
The five types of
SVGViewAttribute
may occur in any order, but each type may only occur at most one time in a correctly formed
SVGViewSpec
When a source document performs a link into an SVG document, for example
via an
HTML anchor element
([
HTML4
], section 12.2; i.e.,

element in HTML) or an
XLink specification [
XLINK
], then
the SVG fragment identifier specifies the initial view into the SVG document,
as follows:
If no SVG fragment identifier is provided (e.g, the specified IRI did
not contain a "#" character, such as
MyDrawing.svg
),
then the initial view into the SVG document is established using the view
specification attributes (i.e.,
‘viewBox’
, etc.) on the
outermost svg element
If the SVG fragment identifier addresses a
‘view’
element within
an SVG document (e.g.,
MyDrawing.svg#MyView
or
MyDrawing.svg#xpointer(id('MyView'))
then the closest ancestor
‘svg’
element is displayed in the viewport.
Any view specification attributes included on the given
‘view’
element override the corresponding view specification attributes on the
closest ancestor
‘svg’
element.
If the SVG fragment identifier addresses specific SVG view (e.g.,
MyDrawing.svg#svgView(viewBox(0,200,1000,1000))
),
then the document fragment defined by the closest ancestor
‘svg’
element is displayed in the viewport using the SVG view specification
provided by the SVG fragment identifier.
If the SVG fragment identifier addresses any element other than a
‘view’
element, then the document defined by the closest ancestor
‘svg’
element is displayed in the viewport using the view
specification attributes on that
‘svg’
element.
17.3.3 Predefined views: the
‘view’
element
The
‘view’
element is defined
as follows:
‘view’
Categories:
None
Content model:
Any number of the following elements, in any order:
descriptive elements
‘desc’
‘metadata’
‘title’
Attributes:
core attributes
‘id’
‘xml:base’
‘xml:lang’
‘xml:space’
‘externalResourcesRequired’
‘viewBox’
‘preserveAspectRatio’
‘zoomAndPan’
‘viewTarget’
DOM Interfaces:
SVGViewElement
Attribute definitions:
viewTarget
= "
XML_Name
[XML_NAME]*
Indicates the target object associated with the view.
Animatable
no.
17.3.4 Highlighting views
It is helpful to users if the target element(s) are highlighted. The visual styling of this highlight should be decided by the document author, because the SVG User Agent has no way to determine what changes would make the elements more visible.
The CSS :target selector ([
SELECTORS
], section 6.2.2) may be used in a stylesheet to provide alternate styling for elements which are the target of links. For example:

17.4 DOM interfaces
17.4.1 Interface SVGAElement
The
SVGAElement
interface corresponds to the
‘a’
element.
interface
SVGAElement
SVGElement
SVGURIReference
SVGTests
SVGLangSpace
SVGExternalResourcesRequired
SVGStylable
SVGTransformable
readonly attribute
SVGAnimatedString
target
};
Attributes:
target
(readonly
SVGAnimatedString
Corresponds to attribute
‘target’
on the given
‘a’
element.
17.4.2 Interface SVGViewElement
The
SVGViewElement
interface corresponds to the
‘view’
element.
interface
SVGViewElement
SVGElement
SVGExternalResourcesRequired
SVGFitToViewBox
SVGZoomAndPan
readonly attribute
SVGStringList
viewTarget
};
Attributes:
viewTarget
(readonly
SVGStringList
Corresponds to attribute
‘viewTarget’
on the given
‘view’
element. A list of DOMString values which contain the names listed in
the
‘viewTarget’
attribute. Each of the DOMString values can be
associated with the corresponding element using the getElementById()
method call.
SVG 1.1 (Second Edition) – 16 August 2011
Top
Contents
Previous
Next
Elements
Attributes
Properties