<a id="image1" href="#"><img src="image.png"></a>
An innocent looking example. An anchor tag containing an image tag. What could be wrong with such a tiny example?
<img src="image.png" id="image1">
The anchor tag isn’t a magical tag that offers up the ability to add an onclick event handler. Any element in your HTML document can have this event added.
This is where the anchor tag could actually come in handy.
For example, if you were going to show a larger version of the image, like in a photo gallery, you should actually have:
<a id="image1" href="largeimage.png"><img scr="image.png"></a>