a

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

* Some parts of this feature may have varying levels of support.

使用 SVG 的锚元素 (<a>) 定义一个超链接。

由于这个元素和 HTML 的 <a> 标签 使用了相同的标签名,当使用 CSS 或 querySelector 选择"a"时,可能应用到错误的元素上。可以尝试使用 @namespace规则 来区分两者

使用上下文

示例

html
<svg
  width="140"
  height="30"
  xmlns="http://www.w3.org/2000/svg"
  xmlns:xlink="http://www.w3.org/1999/xlink">
  <a xlink:href="https://developer.mozilla.org/zh-CN/docs/SVG" target="_blank">
    <rect height="30" width="120" y="0" x="0" rx="15" />
    <text fill="white" text-anchor="middle" y="21" x="60">SVG on MDN</text>
  </a>
</svg>

示例结果:

属性

全局属性

专有属性

DOM 接口

该元素实现了 SVGAElement 接口。

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
a
download
href
hreflang
ping
Experimental
referrerpolicy
no-referrer-when-downgrade
origin-when-cross-origin
unsafe-url
rel
systemLanguage
target
type
xlink:actuate
Deprecated
xlink:href
Deprecated
xlink:show
Deprecated
xlink:title
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Deprecated. Not for use in new websites.