实例
以下代码标记一个按钮:
<button type="button">点我!</button>
浏览器支持

所有主流浏览器都支持 <button> 标签。
标签定义及使用说明
<button> 标签定义一个按钮。
在 <button> 元素内部,您可以放置内容,比如文本或图像。这是该元素与使用 <input> 元素创建的按钮之间的不同之处。
提示:请始终为 <button> 元素规定 type 属性。不同的浏览器对 <button> 元素的 type 属性使用不同的默认值。
提示和注释
注释:如果在 HTML 表单中使用 <button> 元素,不同的浏览器可能会提交不同的按钮值。请使用 <input> 在 HTML 表单中创建按钮。
HTML 4.01 与 HTML5之间的差异
HTML5 中的新属性:autofocus、form、formaction、formenctype、formmethod、formnovalidate 以及 formtarget。
属性
New :HTML5 中的新属性。
属性 |
值 |
描述 |
autofocusNew |
autofocus |
规定当页面加载时按钮应当自动地获得焦点。 |
disabled |
disabled |
规定应该禁用该按钮。 |
formNew |
form_id |
规定按钮属于一个或多个表单。 |
formactionNew |
URL |
规定当提交表单时向何处发送表单数据。覆盖 form 元素的 action 属性。该属性与 type="submit" 配合使用。 |
formenctypeNew |
application/x-www-form-urlencoded
multipart/form-data
text/plain |
规定在向服务器发送表单数据之前如何对其进行编码。覆盖 form 元素的 enctype 属性。该属性与 type="submit" 配合使用。 |
formmethodNew |
get post |
规定用于发送表单数据的 HTTP 方法。覆盖 form 元素的 method 属性。该属性与 type="submit" 配合使用。 |
formnovalidateNew |
formnovalidate |
如果使用该属性,则提交表单时不进行验证。覆盖 form 元素的 novalidate 属性。该属性与 type="submit" 配合使用。 |
formtargetNew |
_blank
_self
_parent
_top
framename |
规定在何处打开 action URL。覆盖 form 元素的 target 属性。该属性与 type="submit" 配合使用。 |
name |
name |
规定按钮的名称。 |
type |
button
reset
submit |
规定按钮的类型。 |
value |
text |
规定按钮的初始值。可由脚本进行修改。 |
全局属性
<button> 标签支持 HTML 的全局属性。
事件属性
<button> 标签支持 HTML 的事件属性。
相关文章
HTML DOM 参考手册:
Button 对象