xlink:href

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The xlink:href attribute defines a reference to a resource as a reference IRI. The exact meaning of that link depends on the context of each element using it.

Note: SVG 2 removed the need for the xlink namespace, so instead of xlink:href you should use href. If you need to support earlier browser versions, the deprecated xlink:href attribute can be used as a fallback in addition to the href attribute, e.g. <use href="some-id" xlink:href="some-id" x="5" y="5" />.

You can use this attribute with the following SVG elements:

Example

html

<svg viewBox="0 0 160 40" xmlns="http://www.w3.org/2000/svg">
  <a xlink:href="https://developer.mozilla.org/">
    <text x="10" y="25">MDN Web Docs</text>
  </a>
</svg>

a

For <a>, xlink:href defines the location of the referenced object.

Value <iri>
Default value None
Animatable Yes

animate, animateMotion, animateTransform, set

For <animate>, <animateMotion>, <animateTransform>, and <set>, xlink:href defines the 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 fragment.

The value must point to exactly one target element which is capable of being the target of the given animation.

If the xlink:href attribute is not provided, the target element will be the immediate parent element of the current animation element.

Refer to the descriptions of the individual animation elements for any restrictions on what types of elements can be targets of particular types of animations.

Value <iri>
Default value None
Animatable No

cursor

For <cursor>, xlink:href defines the reference to the file or element which provides the image of the cursor.

Value <funciri>
Default value None
Animatable Yes

feImage

For <feImage>, xlink:href defines the reference to the image source.

Value <iri>
Default value None
Animatable Yes

filter

For <filter>, xlink:href defines the reference to another <filter> element within the current SVG document fragment. 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.

Value <iri>
Default value None
Animatable Yes

font-face-uri

For <font-face-uri>, xlink:href defines the location of the referenced font.

Value <iri>
Default value None
Animatable No

glyphRef

For <glyphRef>, xlink:href defines to a <glyph> element in an SVG document fragment. The referenced <glyph> is rendered as an alternate glyph.

Value <iri>
Default value None
Animatable No

image

For <image>, xlink:href defines the location of the referenced image.

Value <iri>
Default value None
Animatable Yes

linearGradient

For <linearGradient>, xlink:href defines the reference to a different <linearGradient> or <radialGradient> element within the current SVG document fragment. Any <linearGradient> 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 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.

Value <iri>
Default value None
Animatable Yes

mpath

For <mpath>, xlink:href defines the reference to the <path> element which defines the motion path.

Value <iri>
Default value None
Animatable No

pattern

For <pattern>, xlink:href defines the reference to a different <pattern> element within the current SVG document fragment. 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.

Value <iri>
Default value None
Animatable Yes

radialGradient

For <radialGradient>, xlink:href defines the to a different <linearGradient> or <radialGradient> element within the current SVG document fragment. Any <radialGradient> 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 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.

Value <iri>
Default value None
Animatable Yes

script

For <script>, xlink:href defines a reference to an external resource containing the script code.

Value <iri>
Default value None
Animatable No

textPath

For <textPath>, xlink:href defines a reference to the <path> element onto which the glyphs will be rendered.

Value <iri>
Default value None
Animatable Yes

use

For <use>, xlink:href defines the location of the referenced object.

Value <iri>
Default value None
Animatable Yes

tref

For <tref>, xlink:href defines a reference to an element whose character data content shall be used as character data for this <tref> element.

Value <iri>
Default value None
Animatable Yes

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# XLinkHrefAttribute

Browser compatibility

BCD tables only load in the browser

See also