Log in

View Full Version : How to make the Alt Tag display for a linked image



kuau
08-06-2010, 07:38 AM
Not sure if this is a php or html issue. I had a page of thumbnails which displayed the alt tag when you hovered over the image. This worked well because it displayed the title of the painting so people could find what they were looking for.

I have changed it so that clicking on the thumbnails now links to a separate detail page about the image. The problem is that now when you hover over the thumbnail, it no longer displays the title of the image (alt tag) so you can't be sure you have the right image until you click on it. This is not good.

What seems to have disabled the alt tag display is the <a href=. Does anyone know how to force the alt tag to display for an image even when the image is a link?

Thanks. :)

Beverleyh
08-06-2010, 07:46 AM
If you use the title attribute in your <a href=, it should work as it did before;

<a href="picture.jpg" title="My Picture"><img src="images/picture-thumb.jpg title="My Picture" alt="My Picture" /></a>

Also, I've noticed that you need to also keep the alt and title attribute in the <img> tag so other browsers pick it up too.

Hope that helps :)

kuau
08-06-2010, 08:18 AM
You are my hero! That totally fixed it. Mahalo plenty! :)

Beverleyh
08-06-2010, 12:36 PM
It was something I only stumbled on myself a few weeks ago so it was still quite fresh in my mind :)