HTML <button> Tag

Example

A clickable button is marked up as follows :

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

Definition and Usage

The <button> tag defines a clickable 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.

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


Browser Support

Element Chrome Internet Explorer Firefox Safari Opera
<button> Yes Yes Yes Yes Yes

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.


Differences Between HTML 4.01 and HTML5

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


Attributes

html5badge = New in HTML5.

Attribute Value Description
autofocus html5badgeautofocus Specifies that a button should automatically get focus when the page loads
disabled disabled Specifies that a button should be disabled
form html5badgeform_id Specifies one or more forms the button belongs to
formaction html5badgeURL Specifies where to send the form-data when a form is submitted. Only for type="submit"
formenctype html5badgeapplication/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how form-data should be encoded before sending it to a server. Only for type="submit"
formmethod html5badgeget
post
Specifies how to send the form-data (which HTTP method to use). Only for type="submit"
formnovalidate html5badgeformnovalidate Specifies that the form-data should not be validated on submission. Only for type="submit"
formtarget html5badge_blank
_self
_parent
_top
framename
Specifies where to display the response after submitting the form. Only for type="submit"
name 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

Default CSS Settings

None.