sam
sam

Reputation: 10094

Should you use HTML in an image's alt attribute?

Should you write :

<img src="myimage.jpg" alt="large cat & dog">

or

<img src="myimage.jpg" alt="large cat &amp; dog">

Upvotes: 2

Views: 153

Answers (1)

Quentin
Quentin

Reputation: 944559

The rules for when you should use the entity for an ampersand instead of a single raw & character are the same for the value of an attribute as they are for anywhere else in HTML.

  • You may always use the entity.
  • You must use the entity if the character is followed by a word character (which a space is not).

Upvotes: 5

Related Questions