Praveen_Shukla
Praveen_Shukla

Reputation: 1394

why we are adding alt attributes to content images in html?

<body>
  <img src="cake.png" alt="Cake Photo">
</body>

what is the purpose of writing alt attribute in the above code, if it is for readability then we can show the express intend on src part.

Upvotes: 0

Views: 42

Answers (2)

Michael Herman
Michael Herman

Reputation: 11

The alt part loads if the picture is unable to load. So you can use the alt to provide information to the user about what should be there if it's not.

Upvotes: 1

Andrew
Andrew

Reputation: 20061

"The alt attribute specifies an alternate text for an image, if the image cannot be displayed.

The alt attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute, or if the user uses a screen reader).

Tip: To create a tooltip for an image, use the title attribute!"

http://www.w3schools.com/tags/att_img_alt.asp

Upvotes: 4

Related Questions