Skip to main content
September 29, 2010
Question

dynamically created "alt" attribute not displaying

  • September 29, 2010
  • 1 reply
  • 1220 views

Hi, I have created a details page for our company product, which is diplayed dynamically. I have on this page a dynamic image as well thats pulled from my database. As with any image on the web, I want to set the alt attribute, but of course this has to be dynamic as well. I have done this it seems, as I view my source code from a browser, I can see that the alt has a value there and that it is the correct value. My question is, why doesnt this display when I mouse over the image? Is there something I am forgetting to add? Is this attribute deprecated? here is my code for the alt cfoutput:

<cfoutput>
          <table align="center">
            <tr>
              <td><cfif rsDetails.image1 NEQ "">
                  <a href="images/#rsDetails.image1#" target="_blank"><img src="images/#rsDetails.image1#" alt="#rsDetails.item#" /></a>
                </cfif></td>
            </tr>
          </table>
        </cfoutput>

Here is the source code from the browser that shows there is an alt value:

<table align="center">
    <tr>
       <td>
         <a href="images/60K19DL.jpg" target="_blank"><img src="images/60K19DL.jpg" alt="60K19/DL" /></a>
       </td>
    </tr>
</table>

I hope this is easy to understand without going into lengthy detail. Thanks for any help!

    This topic has been closed for replies.

    1 reply

    Inspiring
    September 29, 2010

    There is no requirement in the HTML spec that alt values appear when one mouses over an image.  Alt is an *alternative* to the image, in environments where images cannot be displayed.  If some browsers display alt text as per your expectation, this is "bonus" behaviour, but it's certainly not the standard behaviour.

    You might be thinking of the TITLE attribute, which I think a lot of browsers display when mousing-over an image?

    --

    Adam

    September 29, 2010

    Hi Adam, once again I'm thanking you for your help! lol So then am I to assume that regardless of whether the mouse over alt is displayed, that google will still use the alt attribute for page ranking and indexing? Or am I confused on this as well?

    Since it has been documented that google web crawlers can not index images, one needs to always provide the alt to make it "readable". Thats my only concern.

    Inspiring
    September 29, 2010

    Search-engine optimisation is a bit of a dark art, and most of the info out there is simply made up by SEO "experts", IMO.  That said web standards say images should have an ALT attribute, so that's a good reason to do it.  I'm sure search engines do bear in mind the values of the alt text: they can't see the picture of a wombat on your wombat page, so won't know that the image content is relevant to the page.  However they will see the alt text, and know that the picture is of a wombat.

    Here's the bumpf from the W3C site:

    http://www.w3.org/TR/REC-html40/struct/objects.html#adef-alt

    --

    Adam