What is the different between <button> and button attribute input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
๐Ÿ‡บ๐Ÿ‡ฆ Vitya ๐Ÿ‡บ๐Ÿ‡ฆ
๐Ÿ‡บ๐Ÿ‡ฆ Vitya ๐Ÿ‡บ๐Ÿ‡ฆ - 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
๐Ÿ‡บ๐Ÿ‡ฆ Vitya ๐Ÿ‡บ๐Ÿ‡ฆ
๐Ÿ‡บ๐Ÿ‡ฆ Vitya ๐Ÿ‡บ๐Ÿ‡ฆ - 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