a

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

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

用法

类别容器元素
允许的内容物任意数量、任意排序的下列元素:
动画元素
描述性元素
形状元素
结构化元素
渐变元素
<a>, <altGlyphDef>, <clipPath>, <color-profile>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view>

示例

<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/en-US/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接口。

浏览器兼容性

Feature Chrome Firefox (Gecko) IE Opera Safari
Basic support 1.0 1.5 (1.8) 9.0 9.0 3.0.4
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 3.0 1.0 (1.8) 未实现 (Yes) 3.0.4

该表格基于这些资源

Note: No browser supports the full XLink set.

文档标签和贡献者