首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

a

<a>SVG元素,定义一个超链接。

由于该元素与HTML的元素共享它的标记名称,因此选择带有CSS或querySelector的“a”可能会应用于错误的元素。尝试使用@namespace规则来区分这两者。

用法上下文

分类

容器元素

允许的内容

任意数量的下列元素,以任何顺序排列:动画元素描述元素图形元素结构元素渐变元素<a>, <altGlyphDef>, <clipPath>, <color-profile>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view>

属性

全局属性

  • Conditional processing attributes
  • Core attributes
  • Graphical event attributes
  • Presentation attributes
  • Xlink attributes
  • class
  • style
  • externalResourcesRequired
  • transform

特殊属性

没有浏览器支持所有的XLink属性。

  • href
  • xlink:show
  • xlink:href

DOM接口

这个元素实现了SVGAElement接口。

SVG

代码语言:javascript
复制
<svg width="140" height="30" xmlns="http://www.w3.org/2000/svg" 
    xmlns:xlink="http://www.w3.org/1999/xlink">

  <a 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>

结果

产品规格

Specification

Status

Comment

Scalable Vector Graphics (SVG) 2The definition of '<a>' in that specification.

Candidate Recommendation

Replaced xlink:href attribute by href

Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of '<a>' in that specification.

Recommendation

Initial definition

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

IE

Opera

Safari

Basic support

1.0

(Yes)

1.5 (1.8)

9.0

9.0

3.0.4

Feature

Android

Edge

Firefox Mobile (Gecko)

IE Phone

Opera Mobile

Safari Mobile

Basic support

3.0

(Yes)

1.0 (1.8)

No support

(Yes)

3.0.4

扫码关注腾讯云开发者

领取腾讯云代金券