【发布时间】:2010-10-02 21:56:49
【问题描述】:
在查看大多数网站(包括 SO)时,他们中的大多数使用:
<input type="button" />
代替:
<button></button>
- 两者之间的主要区别是什么?
- 是否有正当理由使用其中一个而不是另一个?
- 是否有正当理由使用组合它们?
- 使用
<button>是否存在兼容性问题,看到它不是很广泛使用?
【问题讨论】:
-
引用 documentation 截至 2020 年 10 月:
While <input> elements of type button are still perfectly valid HTML, the newer <button> element is now the favored way to create buttons. Given that a <button>’s label text is inserted between the opening and closing tags, you can include HTML in the label, even images. -
@Jakob 我知道 MDN 是一个不错的参考,但我在 HTML5 规范或任何类似 RFC 的文档中找不到类似的建议。
-
@Jakob Mozilla 开发者网络不是“文档”,它是一个公共(志愿者)驱动的资源,其功能更像是一个[方便的]“附录”以被广泛接受类似于 WHATWG 在html.spec.whatwg.org 发布的 HTML 5 规范。
标签: html html-input