hxauyq
Last Updated: February 25, 2016
·
3.06K
· tiagox

Use an alt image for img HTML tags

In case you need to load an alternative image instead to show the classic alt text. You can do this:

<img src="404.png" onerror="this.src='alt.png';" />

Also, you can do anything with Javascript, in case of onerror event.

5 Responses
Add your response

1003

I cant see any code

over 1 year ago ·
1005

What to do.I can't see the code

over 1 year ago ·
1081

The bug is already fixed.

over 1 year ago ·
17051

This can stack overflow if the alternate image is a 404.

over 1 year ago ·
17053

@blainesch you're absolutely right. I didn't thought about that, the alternative image should exist, the idea is to set a default image that you know.

over 1 year ago ·