HTML <button>Tag


Example

The following code marks a button:

<button type="button">Click me!</button>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the <button> tag.


Tag Definition and Usage Instructions

The <button> tag defines a button.

Inside the <button> element, you can place content, such as text or images. This is the difference between this element and buttons created with the <input> element.

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


Tips and Notes

Note:If you use the <button> element in an HTML form, different browsers may submit different button values. Please use<input>to create buttons in an HTML form.


Differences between HTML 4.01 and HTML5

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


Attributes

New: New attributes in HTML5.

Attribute Value Description
autofocusNew autofocus Specifies that the button should automatically get focus when the page loads.
disabled disabled Specifies that the button should be disabled.
formNew form_id Specifies that the button belongs to one or more forms.
formactionNew URL Specifies where to send the form data when the form is submitted. Overrides the action attribute of the form element. This attribute works with type="submit".
formenctypeNew application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how to encode the form data before sending it to the server. Overrides the enctype attribute of the form element. This attribute works with type="submit".
formmethodNew get
post
Specifies the HTTP method used to send form data. Overrides the method attribute of the form element. This attribute works with type="submit".
formnovalidateNew formnovalidate If this attribute is used, the form is not validated when submitted. Overrides the novalidate attribute of the form element. This attribute works with type="submit".
formtargetNew _blank
_self
_parent
_top
framename
Specifies where to open the action URL. Overrides the target attribute of the form element. This attribute works with type="submit".
name name Specifies the name of the button.
type button
reset
submit 
Specifies the type of the button.
value text Specifies the initial value of the button. It can be modified by a script.


Global Attributes

The <button> tag supportsHTML's Global Attributes。


Event Attributes

The <button> tag supportsHTML's Event Attributes。


Related Articles

HTML DOM Reference:Button Object

Other Extensions