HTML5 <button> Tag

Example

A button is marked up as follows:

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

Try it yourself »

Definition and Usage

The <button> tag defines a push button.

Inside a button element you can put content, like text or images. This is the difference between this element and buttons created with the input element.

Always specify the type attribute for the button. Different browsers uses different default values for the type attribute.


Differences Between HTML 4.01 and HTML5

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


Tips and Notes

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


Attributes

New : New in HTML5.

Attribute Value Description
autofocusNew autofocus Specifies that a button should have focus when the page loads
disabled disabled Specifies that a button should be disabled
formNew form_name Specifies which form the button belongs to
formactionNew URL Specifies where to send the form-data when a form is submitted. Overrides the form's action attribute.
Note: Used with type="submit"
formenctypeNew application/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Overrides the form's enctype attribute.
Note: Used with type="submit"
formmethodNew get
post
Specifies how to send form-data. Overrides the form's action attribute.
Note: Used with type="submit"
formnovalidateNew formnovalidate If present, indicates that the form should not be validated when submitted. Overrides the form's novalidate attribute.
Note: Used with type="submit"
formtargetNew _blank
_self
_parent
_top
framename
Specifies where to open the action URL. Overrides the forms target attribute.
Note: Used with type="submit"
name button_name Specifies a name for the button
type button
reset
submit 
Specifies the type of button
value text Specifies an initial value for the button. The value can be changed by a script

Standard Attributes

The <button> tag also supports the Standard Attributes in HTML5.


Event Attributes

The <button> tag also supports the Event Attributes in HTML5.