HTML5 <button> Tag

Example

A button coded as below::

<button type="button">Hai Everyone!</button>
Code it Online »

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

Attribute Value Description
autofocus autofocus Specifies that a button should have focus when the page loads
disabled disabled Specifies that a button should be disabled
form form_name Specifies which form the button belongs to
formaction URL Specifies where to send the form-data when a form is submitted. Overrides the form's action attribute.
Note: Used with type="submit"
formenctype 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"
formmethod get
post
Specifies how to send form-data. Overrides the form's action attribute.
Note: Used with type="submit"
formnovalidate formnovalidate If present, indicates that the form should not be validated when submitted. Overrides the form's novalidate attribute.
Note: Used with type="submit"
formtarget _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.


Have Any Suggestion? We Are Waiting To Hear from YOU!

Your Query was successfully sent!