Results 1 to 4 of 4

Thread: How to make the Alt Tag display for a linked image

  1. #1
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default How to make the Alt Tag display for a linked image

    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.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    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
    Last edited by Beverleyh; 08-06-2010 at 07:46 AM. Reason: code corrected
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    kuau (08-06-2010)

  4. #3
    Join Date
    Sep 2007
    Location
    Maui
    Posts
    642
    Thanks
    284
    Thanked 15 Times in 15 Posts

    Default

    You are my hero! That totally fixed it. Mahalo plenty!

  5. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    It was something I only stumbled on myself a few weeks ago so it was still quite fresh in my mind
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •