+ 13

What is the different between <button> and button attribute input?

<button>click</button> <Input type="button" value="submit">

27th Apr 2022, 11:20 PM
Usman Shinwari🩂
Usman Shinwari🩂 - avatar
4 Answers
+ 9
The difference is very subtle for your browser, but it's out there. You can use them interchangeably for your advantage in code. For example, to make a single <button> stand out from the "crowd" of other input types. However <button> tags are containers, hence technically they can contain other HTML elements. Keep in my mind, that the text inside the button can be highlighted with a long tap. Beware of that, when making some kind of action game, because a long tap can completely disable your button. Then you gonna need some boiler plate code to avoid it, or simply use <input> tags. Changing of the caption is obviously a bit different. When you make a "Play/Pause" button using an <input> tag, you'd change the value attribute. With a <button> tag — textContent... Or innerHTML 😀.
8th Jul 2022, 2:51 PM
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩 - avatar
+ 9
You can find some of that boiler plate code in the answers to one of my old question 👇: https://www.sololearn.com/Discuss/2351784/?ref=app
8th Jul 2022, 2:55 PM
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩
đŸ‡ș🇩 Drake CDR đŸ‡ș🇩 - avatar
+ 5
Hmm you can use the button tag inside a form tag with type submit. And on the other hand you could change type from the input tag with Javascript. I don't know if that make sense. So the different is they have different attributes.
27th Apr 2022, 11:46 PM
Stefanoo
Stefanoo - avatar
+ 3
đŸ€”
28th Apr 2022, 10:16 AM
Razaq Ahmad
Razaq Ahmad - avatar