Reputation: 2276
I wanna ask about the alt attribute in an input tag. As I found on many sites, the alt attribute is used when we have an input with type image.
1/ Can it be used for an input type button?
<input type="button" alt="myAction.myMethod" />
2/ what is its meaning?
Upvotes: 13
Views: 37455
Reputation: 6339
The attribute that defines the mouse hover tooltip text is title
, not alt
, as asked and answered in Tooltips for Button elements.
The title
attribute documentation page at https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/title (MDN) also has a few notes about accessibility issues for the tooltip effect on mouse over and suggests some alternative techniques.
Upvotes: 36
Reputation: 331
For a button class I found it was title="Copy to clipboard"
that worked for me.
Upvotes: 2
Reputation: 863
See http://www.w3schools.com/tags/att_input_alt.asp I quote
The alt attribute provides an alternate text for the user, if he/she for some reason cannot view the image (because of slow connection, an error in the src attribute, or if the user uses a screen reader).
Note: The alt attribute can only be used with <input type="image">.
So, no. And since it cannot be used with a button, it has no meaning.
Upvotes: 1
Reputation: 944113
The only kind of input that can have an alt
attribute is type="image"
where it provides a text alternative for when the image can't be rendered (e.g. because it failed to load, because the browser doesn't support images, or because the user is employing screen reader software (usually to compensate for a vision related disability)).
Upvotes: 4