Friday, 26th February 2010
<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.
Of course, the noise issue is secondary to another
issue with this example: What happens if the user or device doesn't use
prevents any further execution of your code?
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>
And then override this default behaviour
page or even animate it on and off the page (whatever you like!)