Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the img tag's alt attribute require encoding?

In html does the text inside the img tag's alt attribute require encoding/escaping?

Non encoded example:

<img src="myimg.png" alt="image description" />

Encoded example:

<img src="myimg.png" alt="image%20description" />
like image 332
stukelly Avatar asked Jul 22 '09 14:07

stukelly


1 Answers

No, it does not need to be encoded like a URI. However, HTML characters must be encoded, like this...

<img src="myimg.png" alt="Me &amp; my image" />
like image 67
Josh Stodola Avatar answered Oct 22 '22 15:10

Josh Stodola