xlink:href

« SVG Attribute reference home

The xlink:href attribute basically define a link to a resource as a reference <IRI>. The exact meaning of that link depend on the context of each element using it, see above for more specific usage.

Usage context

Categories Xlink attribute
Value <IRI> | <funcIRI>
Animatable No (with some exceptions)
Normative document SVG 1.1 (2nd Edition): Animation elements
SVG 1.1 (2nd Edition): a element
SVG 1.1 (2nd Edition): altGlyph element
SVG 1.1 (2nd Edition): color-profile element
SVG 1.1 (2nd Edition): cursor element
SVG 1.1 (2nd Edition): feImage element
SVG 1.1 (2nd Edition): filter element
SVG 1.1 (2nd Edition): font-face-uri element
SVG 1.1 (2nd Edition): glyphRef element
SVG 1.1 (2nd Edition): image element
SVG 1.1 (2nd Edition): linearGradient element
SVG 1.1 (2nd Edition): mpath element
SVG 1.1 (2nd Edition): pattern element
SVG 1.1 (2nd Edition): radialGradient element
SVG 1.1 (2nd Edition): script element
SVG 1.1 (2nd Edition): textPath element
SVG 1.1 (2nd Edition): use element
SVG 1.1 (2nd Edition): tref element

<IRI>

An Internationalized Resource Identifier.

On the Internet, resources are identified using IRIs (Internationalized Resource Identifiers). For example, an SVG file called someDrawing.svg located at http://example.com might have the following IRI:

http://example.com/someDrawing.svg

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:

http://example.com/someDrawing.svg#Lamppost

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 <FuncIRI> 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:

<linearGradient xml:id="MyGradient">...</linearGradient>

You then reference the linear gradient as the value of the fill attribute for the rectangle, as in the following example:

<rect fill="url(#MyGradient)"/>

SVG supports two types of IRI references:

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

For the full specification of IRI references in SVG, see SVG 1.1 (2nd Edition): IRI references.

Elements

The following elements can use the xlink:href attribute

Animation elements »
An <IRI> reference to the element which is the target of this animation and which therefore will be modified over time. The target element must be part of the current SVG document. If the xlink:href attribute is not provided, then the target element will be the immediate parent element of the current animation element.
Gradient elements »
An <IRI> reference to a different <lineargradient> or <radialgradient> element within the current SVG document. Any <lineargradient> or <lineargradient> attributes which are defined on the referenced element which are not defined on this element are inherited by this element if this element is of the same type as the referenced element. If this element has no defined gradient stops, and the referenced element does (possibly due to its own xlink:href attribute), then this element inherits the gradient stop from the referenced element. Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attribute or gradient stops due to its own xlink:href attribute, then the current element can inherit those attributes or gradient stops. On the gradient elements, the xlink:href attribute is animatable.
<a>
The location of the referenced object, expressed as an <IRI> reference. On the <a> element, the xlink:href attribute is animatable.
<altglyph>
An <IRI> reference either to a <glyph> element in an SVG document or to an <altglyphdef> element.

If the reference is to a <glyph> element and that glyph is available, then that glyph is rendered instead of the character(s) that are inside of the <altglyph> element.

If the reference is to an <altglyphdef> element, then if an appropriate set of alternate glyphs is located from processing the <altglyphdef> element, then those alternate glyphs are rendered instead of the character(s) that are inside of the <altglyph> element.
<color-profile>
The location of an ICC profile resource.
<cursor>
A <funcIRI> reference to the file or element which provides the image of the cursor. On the <cursor> element, the xlink:href attribute is animatable.
<feimage>
An <IRI> reference to the image source. On the <feimage> element, the xlink:href attribute is animatable.
<filter>
An <IRI> reference to another <filter> element within the current SVG document. Any attributes which are defined on the referenced <filter> element which are not defined on this element are inherited by this element. If this element has no defined filter nodes, and the referenced element has defined filter nodes (possibly due to its own xlink:href attribute), then this element inherits the filter nodes defined from the referenced <filter> element. Inheritance can be indirect to an arbitrary level; thus, if the referenced <filter> element inherits attributes or its filter node specification due to its own xlink:href attribute, then the current element can inherit those attributes or filter node specifications. On the <filter> element, the xlink:href attribute is animatable.
<font-face-uri>
The xlink:href attribute specifies the location of the referenced font.
<glyphref>
An <IRI> reference to a <glyph> element in an SVG document. The referenced <glyph> is rendered as an alternate glyph.
<image>
An <IRI> reference to the image source. On the <image> element, the xlink:href attribute is animatable.
<mpath>
An <IRI> reference to the <path> element which defines the motion path.
<pattern>
An <IRI> reference to a different <pattern> element within the current SVG document. Any attributes which are defined on the referenced element which are not defined on this element are inherited by this element. If this element has no children, and the referenced element does (possibly due to its own xlink:href attribute), then this element inherits the children from the referenced element. Inheritance can be indirect to an arbitrary level; thus, if the referenced element inherits attributes or children due to its own xlink:href attribute, then the current element can inherit those attributes or children. On the <pattern> element, the xlink:href attribute is animatable.
<script>
An <IRI> reference to an external resource containing the script code.
<textpath>
An <IRI> reference to the <path> element onto which the text will be rendered. On the <textpath> element, the xlink:href attribute is animatable.
<use>
An <IRI> reference to an element/fragment within an SVG document. On the <use> element, the xlink:href attribute is animatable.
<tref>
An <IRI> reference to an element whose character data content shall be used as character data for this <tref> element. On the <tref> element, the xlink:href attribute is animatable.

Document Tags and Contributors

 Contributors to this page: Jeremie
 Last updated by: Jeremie,