Jump to content

the illusive ALT attibute


george

Recommended Posts

The alt attibute in an image tag works great. It would be great if I could have an "alt" attribute for a button, or a cell in a table. I know I can capture an onmouseover event with either of these, but then how do I display a message? No alert box for this, I need a message to be like a hint or alt message. I don't want to have to write a routine to display a hidden message on rollover, because the alt and the hint already do that. In standard javascript is there a hint attibute?

Link to comment
Share on other sites

I think you may be looking for the "title" attribute.

<button title="Click me to alert something!" onclick="alert('something');">Click Me!</button>

Link to comment
Share on other sites

The title is actually the standard way to do what you want for all elements; alt is for when an image can't be displayed (i.e. because it wasn't found or the medium doesn't support images - like Braille or voice readers) and you need to describe it to the user. If an image doesn't have a title, it will default to its alt attribute instead.

Link to comment
Share on other sites

The title is actually the standard way to do what you want for all elements; alt is for when an image can't be displayed (i.e. because it wasn't found or the medium doesn't support images - like Braille or voice readers) and you need to describe it to the user. If an image doesn't have a title, it will default to its alt attribute instead.
If an image doesn't have a title attribute it shouldn't show anything in the tooltip. Internet Explorer is the only browser that displays a tooltip using the alt attribute.
Link to comment
Share on other sites

LOL, woops. I guess I haven't tested that since I started using Firefox. My Webmastering teacher always used alt as title, but then I heard about title and assumed that he was halfway correct. (That's the same teacher that told everyone to use tables for layout, lol...)

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...