3

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>
Deduplicator
  • 44,692
  • 7
  • 66
  • 118
Martin York
  • 257,169
  • 86
  • 333
  • 562
  • `alt` attribute is not valid on the `svg` element, see [this](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/svg#Specific_attributes) for available attributes. `` tags must also have a `src` attribute. – Kyle Needham Apr 02 '14 at 22:02
  • @KyleNeedham: So what is the conical way to put alternative text on a page for an imbedded svg image (ie for not visual browsers). – Martin York Apr 02 '14 at 22:13
  • You could do `alt text here` that way you can get support for most browsers (even IE6). – Kyle Needham Apr 02 '14 at 22:24
  • 1
    See also http://stackoverflow.com/questions/4697100/accessibility-recommended-alt-text-convention-for-svg-and-mathml – gerwitz Oct 07 '14 at 08:22

1 Answers1

6

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

<svg width="120" height="35">
  <desc>Stuff</desc>
  {{ STUFF }}
</svg>
Robert Longson
  • 118,664
  • 26
  • 252
  • 242