0

I am writing an alt attribute for an image and it includes an ampersand. Should I put the HTML character code, & in the alt attribute or can I just put an ampersand? Would the same be true for the title attribute?

<img alt="This & that"/>

versus

<img alt="This &amp; that"/>
  • 1
    http://www.w3.org/TR/html5/dom.html#attributes and http://www.w3.org/TR/html5/embedded-content-0.html#alt – Matt Ball May 21 '13 at 16:54
  • Can you show us your code? – Majo0od May 21 '13 at 16:55
  • I don't think there is any need for code, if you look at Matt's links, you are fine adding in the ampersand. (Though I recommend simply switching it to and) – illinoistim May 21 '13 at 17:06
  • 1
    @naivists, OP's question is related to an image tag, not a title tag. – illinoistim May 21 '13 at 17:08
  • You should use either `&` or the word and like IllinoisTim mentioned. Doing `alt="logo for Tom & Jerry"` will be a validator warning since "`& `" is not a valid entity. – Ryan B May 21 '13 at 18:23

0 Answers0