Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. SVG
  3. Reference
  4. Attributes
  5. href

href

Thehref attribute defines a link to a resource as a referenceURL. The exact meaning of that link depends on the context of each element using it.

Note:Specifications before SVG 2 defined anxlink:href attribute, which is now rendered obsolete by thehref attribute. If you need to support earlier browser versions, the deprecatedxlink:href attribute can be used as a fallback in addition to thehref 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,body,svg {  height: 100%;}
html
<svg viewBox="0 0 160 40" xmlns="http://www.w3.org/2000/svg">  <a href="https://developer.mozilla.org/">    <text x="10" y="25">MDN Web Docs</text>  </a></svg>

In SVG

a

For<a>,href defines the location of the referenced object, expressed as a URL reference.

Value<url>
Default valueNone
AnimatableYes

animate, animateMotion, animateTransform, set

For the<animate>,<animateMotion>,<animateTransform>, and<set>,href defines a URL referring to the element which is the target of this animation element and which therefore will be modified over time.

The URL must point to exactly one target element which is capable of being the target of the given animation element. If the URL points to multiple target elements, if the given target element is not capable of being a target of the given animation element, or if the given target element is not part of the current document, then the animation element will not affect any target element. However, the animation element will still operate normally with regard to its timing properties. Specifically, TimeEvents are dispatched and the animation element can be used as syncbase in an identical fashion to when the URL refers to a valid target element.

If thehref attribute or the deprecatedxlink:href attribute is not provided, then the target element will be the immediate parent element of the current animation element. If bothxlink:href andhref are specified, the value of the latter attribute is used.

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.

Except for any SVG-specific rules explicitly mentioned in this specification, the normative definition for this attribute is theSMIL Animation specification. In particular, seeSMIL Animation: Specifying the animation target.

Value<url>
Default valueNone
AnimatableNo

feImage

For<feImage>,href defines a URL referring to an image resource or to an element. If both, thexlink:href and thehref attribute are specified, the latter overrides the former.

Value<url>
Default valueNone
AnimatableYes

image

For<image>,href defines a URL referring to the image to render.

Value<url>
Default valueNone
AnimatableYes
html,body,svg {  height: 100%;}
html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">  <image href="fxlogo.png" x="0" y="0" height="100" width="100" /></svg>

linearGradient/radialGradient

For<linearGradient> or<radialGradient>,href defines URL referring to a template gradient element; to be valid, the reference must be to a different<linearGradient> or<radialGradient> element.

Value<url>
Default valueNone
AnimatableYes

mpath

For<mpath>,href defines a URL referring to the<path> element orbasic shape which defines the motion path.

Value<url>
Default valueNone
AnimatableNo

pattern

For<pattern>,href defines a URL referring 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 ownhref 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 ownhref attribute, then the current element can inherit those attributes or children. On the<pattern> element, thehref attribute is animatable.

Value<url>
Default valueNone
AnimatableYes

script

For<script>,href defines a URL referring to an external resource containing the script code.

Value<url>
Default valueNone
AnimatableNo

textPath

For<textPath>,href defines a URL referring to the<path> element orbasic shape onto which the text will be rendered if nopath attribute is provided. On the<textPath> element, thehref attribute is animatable.

Value<url>
Default valueNone
AnimatableYes

use

For<use>,href defines a URL referring to an element or fragment within an SVG document to be cloned.

The<use> element can reference an entire SVG document by specifying anhref value without a fragment. Such references are taken to be referring to the root element of the referenced document.

Value<url>
Default valueNone
AnimatableYes

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# AElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# ImageElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# LinearGradientElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# PatternElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# RadialGradientElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# ScriptElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# TextPathElementHrefAttribute
Scalable Vector Graphics (SVG) 2
# UseElementHrefAttribute
SVG Animations Level 2
# HrefAttribute
SVG Animations Level 2
# MPathElementHrefAttribute
Filter Effects Module Level 1
# element-attrdef-feimage-href

Browser compatibility

svg.elements.a.href

svg.elements.animate.href

svg.elements.animateMotion.href

svg.elements.animateTransform.href

svg.elements.feImage.href

svg.elements.image.href

svg.elements.linearGradient.href

svg.elements.mpath.href

svg.elements.pattern.href

svg.elements.radialGradient.href

svg.elements.script.href

svg.elements.set.href

svg.elements.textPath.href

svg.elements.use.href

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp