等效于SVG <img/>元素的Alt标签

时间:2019-04-13 17:16:25

标签: html image svg accessibility alt

当我使用<img> HTML标记时,我总是使用alt属性来实现可访问性。

alt="some text"添加到SVG <image>元素中似乎无效吗?

在此示例中,提供替代文本的最佳方法是什么?

我必须使用SVG <image>元素,所以我无法采用其他DOM元素答案。

<svg x="0px" y="0px" viewBox="0 0 910 1295" style="enable-background:new 0 0 910 1295;" xml:space="preserve">
  <image width="910" height="1295" xlink:href="https://i.postimg.cc/43DKn46z/colours.jpg">
  </image>
</svg>

在此先感谢您的帮助。

1 个答案:

答案 0 :(得分:3)

SVG中的alt标签等效于<desc>子元素。

<svg x="0px" y="0px" viewBox="0 0 910 1295" style="enable-background:new 0 0 910 1295;" xml:space="preserve">
  <image width="910" height="1295" xlink:href="https://i.postimg.cc/43DKn46z/colours.jpg">
    <desc>Some description of the image</desc>
  </image>
</svg>
相关问题