---
title:
slug: Web/SVG/Element/a
tags:
- Element
- Reference
- SVG
- SVG Container
- SVG コンテナー
- 要素
translation_of: Web/SVG/Element/a
---
<a> は SVG の要素で、他のウェブページ、ファイル、同じページ内の場所、メールアドレス、その他の URL へのハイパーリンクを生成します。 HTML の {{htmlelement("a")}} 要素ととても良く似ています。 SVG の {{EmbedLiveSample('Example', 100, 100)}} この要素は HTML の {{svginfo}}<a> 要素はコンテナーですので、 (HTML のような) テキストを囲むものだけでなく、図形を囲むリンクを生成することもできます。@namespace svg url(http://www.w3.org/2000/svg);
html,body,svg { height:100% }
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<!-- 図形を囲むリンク -->
<a href="/ja/docs/Web/SVG/Element/circle">
<circle cx="50" cy="40" r="35"/>
</a>
<!-- テキストを囲むリンク -->
<a href="/ja/docs/Web/SVG/Element/text">
<text x="50" y="90" text-anchor="middle">
<circle>
</text>
</a>
</svg>
/* SVG ではリンクに既定の視覚スタイルがないので、
何かを追加するのがいいでしょう */
@namespace svg url(http://www.w3.org/2000/svg);
/* SVG の <a> 要素のみを選択し、 HTML を除外するために必要。
下記の警告を参照 */
svg|a:link, svg|a:visited {
cursor: pointer;
}
svg|a text,
text svg|a {
fill: blue; /* テキストであっても、 SVG は塗りつぶし色を使用する */
text-decoration: underline;
}
svg|a:hover, svg|a:active {
outline: dotted 1px blue;
}
<a> 要素と同じタグ名なので、 a を CSS や {{domxref("Document.querySelector", "querySelector")}} で選択すると、誤った種類の要素に適用してしまう可能性があります。 @namespace 規則で二つを区別してみてください。属性
値種別: <string> ; 既定値: none; アニメーション: no
値種別: <URL> ; 既定値: none; アニメーション: yes
値種別: <string> ; 既定値: none; アニメーション: yesPING であるものがブラウザーから (バックグラウンドで) 送信されます。通常はトラッキングのために使用されます。同じ用途でもっと広く対応されている機能として、 {{domxref("Navigator.sendBeacon()")}} を参照してください。
値種別: <list-of-URLs> ; 既定値: none; アニメーション: no
値種別: no-referrer|no-referrer-when-downgrade|same-origin|origin|strict-origin|origin-when-cross-origin|strict-origin-when-cross-origin|unsafe-url ; 既定値: none; アニメーション: no
値種別: <list-of-Link-Types> ; 既定値: none; アニメーション: yes
値種別: _self|_parent|_top|_blank|<name> ; 既定値: _self; アニメーション: yes
値種別: <string> ; 既定値: none; アニメーション: yes
値種別: <URL> ; 既定値: none; アニメーション: yesグローバル属性
aria-activedescendant, aria-atomic, aria-autocomplete, aria-busy, aria-checked, aria-colcount, aria-colindex, aria-colspan, aria-controls, aria-current, aria-describedby, aria-details, aria-disabled, aria-dropeffect, aria-errormessage, aria-expanded, aria-flowto, aria-grabbed, aria-haspopup, aria-hidden, aria-invalid, aria-keyshortcuts, aria-label, aria-labelledby, aria-level, aria-live, aria-modal, aria-multiline, aria-multiselectable, aria-orientation, aria-owns, aria-placeholder, aria-posinset, aria-pressed, aria-readonly, aria-relevant, aria-required, aria-roledescription, aria-rowcount, aria-rowindex, aria-rowspan, aria-selected, aria-setsize, aria-sort, aria-valuemax, aria-valuemin, aria-valuenow, aria-valuetext, role使用上の注意
仕様書
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName("SVG2", "linking.html#Links", "<a>")}} | {{Spec2("SVG2")}} | {{SVGAttr("xlink:href")}} 属性を {{SVGAttr("href")}} で置き換え |
| {{SpecName("SVG1.1", "linking.html#Links", "<a>")}} | {{Spec2("SVG1.1")}} | 初回定義 |
{{Compat("svg.elements.a")}}