Latest web development tutorials

HTML <button> tag

Examples

The following code marking a button:

<button type="button">点我!</button>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <button> tag.


Tag definitions and instructions

<Button> tag defines a button.

In the <button> inside the element, you can place the content, such as text or images. This is the difference between the element and use <input> element to create the button between.

Tip: Always <button> element specifies the type attribute.Different browsers use different default values ​​for the type attribute <button> element.


Tips and Notes

NOTE: If you use the <button> element in an HTML form, different browsers may submit a different button values.Please use the <input> Create button in an HTML form.


Differences between HTML 4.01 and HTML5

HTML5 new attributes: autofocus, form, formaction, formenctype, formmethod, formnovalidate and formtarget.


Attributes

New: HTML5 new property.

属性 描述
autofocus New autofocus 规定当页面加载时按钮应当自动地获得焦点。
disabled disabled 规定应该禁用该按钮。
form New form_id 规定按钮属于一个或多个表单。
formaction New URL 规定当提交表单时向何处发送表单数据。覆盖 form 元素的 action 属性。该属性与 type="submit" 配合使用。
formenctype New application/x-www-form-urlencoded
multipart/form-data
text/plain
规定在向服务器发送表单数据之前如何对其进行编码。覆盖 form 元素的 enctype 属性。该属性与 type="submit" 配合使用。
formmethod New get
post
规定用于发送表单数据的 HTTP 方法。覆盖 form 元素的 method 属性。该属性与 type="submit" 配合使用。
formnovalidate New formnovalidate 如果使用该属性,则提交表单时不进行验证。覆盖 form 元素的 novalidate 属性。该属性与 type="submit" 配合使用。
formtarget New _blank
_self
_parent
_top
framename
规定在何处打开 action URL。覆盖 form 元素的 target 属性。该属性与 type="submit" 配合使用。
name name 规定按钮的名称。
type button
reset
submit 
规定按钮的类型。
value text 规定按钮的初始值。可由脚本进行修改。


Global Properties

<button> tag supports HTML global properties .


Event Properties

<button> tag supports HTML event properties .


related articles

HTML DOM Reference Manual: the Button objects