HTML5 svg tag and alt attribute

巧了我就是萌 提交于 2021-02-10 12:35:14

问题


Not an expert in HTML and checking the correct behavior of an HTML parser (looking for correct behavior according to html5 not good or expect (we can handle that later)).

In the new HTML5 <svg> tag is it valid to place the "alt" attribute?

<svg width="120" height="35" alt="Stuff">
  {{ STUFF }}
</svg>

Or should the <svg> be imbedded inside an <img> to achieve this?

<img alt="Stuff">
   <svg width="120" height="35">
      {{ STUFF }}
   </svg>
</img>

回答1:


SVG doesn't have an alt attribute, it uses a <desc> child tag instead.

<svg width="120" height="35">
  <desc>Stuff</desc>
  {{ STUFF }}
</svg>


来源:https://stackoverflow.com/questions/22823770/html5-svg-tag-and-alt-attribute

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!