What's the difference between <input type=“button” /> and <button>?

為{幸葍}努か 提交于 2020-01-10 19:52:06

问题


I didn’t know about the <button> tag until today.


回答1:


Basically, <button> is more flexible as it can contain other tags inside it. Like,

<button type="submit"><strong>Click</strong> me, <em>user!</em></button>

You won't be able to do this with regular <input>.




回答2:


Check this article

Inputs vs Buttons

Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to “image”, but the BUTTON element type allows content.




回答3:


You can include images in a <button> tag, but not in an <input> tag, amoung other differences




回答4:


See: W3C site.

They are very similar but the <button> tag has a few extras that can be useful on the odd occasion.



来源:https://stackoverflow.com/questions/1398955/whats-the-difference-between-input-type-button-and-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!