Can The Alt Attribute Be Used For An Input Type Button - Stack Overflow

Just browsing Stack Overflow? Help us improve your experience. Sign up for research
    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs can the alt attribute be used for an input type button Ask Question Asked 10 years, 3 months ago Modified 2 years, 3 months ago Viewed 36k times 12

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?

Share Improve this question Follow asked Aug 21, 2014 at 9:39 senior's user avatar seniorsenior 2,2566 gold badges40 silver badges57 bronze badges 5
  • Why would you use it with a button input anyway? – BoltClock Commented Aug 21, 2014 at 9:41
  • This attribute is used for `<img> – singe3 Commented Aug 21, 2014 at 9:43
  • 1 Perhaps if you mention what you want to achieve with this, hints could be given as to what tag you should be using. – Sanchises Commented Aug 21, 2014 at 9:49
  • Do you actually want to ask how to set some text in an input element of type button? – Jukka K. Korpela Commented Aug 21, 2014 at 9:49
  • The ask perhaps for accessibility. No, we can't add alt text because it doesn't make sense with the button, but for accessibility, we can add aria-label. – Rashid Commented Nov 5, 2021 at 16:44
Add a comment |

4 Answers 4

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 34

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.

Share Improve this answer Follow edited Aug 11, 2022 at 7:20 answered Oct 22, 2018 at 17:15 handle's user avatar handlehandle 6,2794 gold badges60 silver badges91 bronze badges Add a comment | 4
  1. No
  2. It doesn't have one

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)).

Share Improve this answer Follow answered Aug 21, 2014 at 9:42 Quentin's user avatar QuentinQuentin 941k132 gold badges1.3k silver badges1.4k bronze badges Add a comment | 2

For a button class I found it was title="Copy to clipboard" that worked for me.

Share Improve this answer Follow answered Oct 21, 2021 at 14:31 Spinstaz's user avatar SpinstazSpinstaz 3317 silver badges12 bronze badges Add a comment | 1

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.

Share Improve this answer Follow edited Oct 11, 2017 at 20:10 Sean the Bean's user avatar Sean the Bean 5,3825 gold badges39 silver badges40 bronze badges answered Aug 21, 2014 at 9:42 Sanchises's user avatar SanchisesSanchises 8634 silver badges24 bronze badges Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • Featured on Meta
  • We’re (finally!) going to the cloud!
  • More network sites to see advertising test [updated with phase 2]

Linked

433 Tooltips for Button elements 1 Use of alt in button tag 17 Is alt="" appropriate in some situations for html img tag? 0 Simple HTML "ALT" Tag Question. Please Help! 0 Why isn't alt a valid attribute for <input>? 0 Does HTML attribute 'alt' work with numbers? 0 How to use ALT tag correctly? 0 How do I use the alt attribute tag 4 Can an alt attribute be set using CSS? 0 Accessing a button's alt text using jQuery 11 Is alt the same as alt=""? 0 Can there be more than one alt attribute on an image?

Hot Network Questions

  • Have you it there?
  • How do I hover in the Tails mech?
  • The usage of Select for list (deep level)
  • Bode diagram of rauch filter
  • How to change the size of the text under min and arg min commands?
  • What are Christian responses to Carlo Alvaro's argument against Christian theism?
  • A fantasy movie with two races, "Big Ones" (=us) and smaller ones, about saving a newborn baby from a cruel queen
  • Are garbage-collection programming languages inherently unsafe for use in cryptography
  • Outlet Wiring Gone Wrong
  • How can I insulate a cramped crawl space?
  • Who is the "Sea-queen" mentioned in "Oedipus", and why is she referenced?
  • What is the command to clear an entire line in Linux using Super + Backspace, like on Mac with Command (hold) + Backspace (tap)?
  • Why motion of gas never stops?
  • Isomorphic Free Groups Have Bijective Sets Using Category Theory
  • How do I report to Springer a scientific fraud to a cryptographic paper published in Springer?
  • Do additionally installed drivers survive Windows 11 "Reset this PC"?
  • In AES GCM, would using different nonces that are close reveal data?
  • How to make seal on lever flip-top "Kilner" jars without spoiling sterilization?
  • Are there any tests for knowing whether a topological space admits a CW structure?
  • Can Trump reverse President Joe Biden's pardon for his son?
  • Use debs from the ubutu pro subscription to the unsubscribed machine
  • Series about people who get infected with worms
  • Are my basic implemetations of AES-CBC and AES-GCM in PHP secure?
  • Pros & cons of Sallen-Key vs. double RC cascaded stages low pass filter topologies
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-html

Từ khóa » Html Alt Text For Buttons