xlink:href - SVG: Scalable Vector Graphics 编辑

Deprecated since SVG 2

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.

22 elements are using this attribute: <a>, <altGlyph>, <animate>, <animateColor>, <animateMotion>, <animateTransform>, <color-profile>, <cursor>, <feImage>, <filter>, <font-face-uri>, <glyphRef>, <image>, <linearGradient>, <mpath>, <pattern>, <radialGradient>, <script>, <set>, <textPath>, <tref>, and <use>}

html, body, svg {
  height: 100%;
}
<svg viewBox="0 0 160 40" xmlns="http://www.w3.org/2000/svg">
  <a xlink:href="/wiki/"><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 valueNone
AnimatableYes

altGlyph

For <altGlyph>, xlink:href defines the reference either to a <glyph> element in an SVG document fragment 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 characters 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 characters that are inside of the <altGlyph> element.

Value<iri>
Default valueNone
AnimatableNo

animate, animateColor, animateMotion, animateTransform, set

For <animate>, <animateColor>, <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 valueNone
AnimatableNo

color-profile

For <color-profile>, xlink:href defines the location of an ICC profile resource.

Value<iri>
Default valueNone
AnimatableNo

cursor

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

Value<funciri>
Default valueNone
AnimatableYes

feImage

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

Value<iri>
Default valueNone
AnimatableYes

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 valueNone
AnimatableYes

font-face-uri

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

Value<iri>
Default valueNone
AnimatableNo

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 valueNone
AnimatableNo

image

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

Value<iri>
Default valueNone
AnimatableYes

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 valueNone
AnimatableYes

mpath

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

Value<iri>
Default valueNone
AnimatableNo

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 valueNone
AnimatableYes

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 valueNone
AnimatableYes

script

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

Value<iri>
Default valueNone
AnimatableNo

textPath

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

Value<iri>
Default valueNone
AnimatableYes

use

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

Value<iri>
Default valueNone
AnimatableYes

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 valueNone
AnimatableYes

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <a>' in that specification.
RecommendationDefines href for the <a> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <altGlyph>' in that specification.
RecommendationDefines href for the <altGlyph> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <animate>, <animateColor>, <animateMotion>, <animateTransform>, and <set>' in that specification.
RecommendationDefines href for animation elements.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <color-profile>' in that specification.
RecommendationDefines href for the <color-profile> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <cursor>' in that specification.
RecommendationDefines href for the <cursor> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <feImage>' in that specification.
RecommendationDefines href for the <feImage> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <filter>' in that specification.
RecommendationDefines href for the <filter> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <font-face-uri>' in that specification.
RecommendationDefines href for the <font-face-uri> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <glyphRef>' in that specification.
RecommendationDefines href for the <glyphRef> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <image>' in that specification.
RecommendationDefines href for the <image> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <linearGradient>' in that specification.
RecommendationDefines href for the <linearGradient> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <mpath>' in that specification.
RecommendationDefines href for the <mpath> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <pattern>' in that specification.
RecommendationDefines href for the <pattern> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <radialGradient>' in that specification.
RecommendationDefines href for the <radialGradient> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <script>' in that specification.
RecommendationDefines href for the <script> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <textPath>' in that specification.
RecommendationDefines href for the <textPath> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <use>' in that specification.
RecommendationDefines href for the <use> element.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'href for <tref>' in that specification.
RecommendationDefines href for the <tref> element.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:61 次

字数:28300

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文