Jump to content

the illusive ALT attibute


george
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...