Tag <button> HTML Reference



Example

A button is marked up as follows:

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

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

1. 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.

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


2. Tips and Notes

Important: If you use the <button> element in an HTML form, different browsers may submit different values. Internet Explorer, prior version 9, will submit the text between the <button> and </button> tags, while other browsers will submit the content of the value attribute. Use the <input> element to create buttons in an HTML form.


3. Differences Between HTML 4.01 and HTML5

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


4. Optional Attributes

DTD indicates in which HTML 4.01/XHTML 1.0 DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
disabled disabled Specifies that a button should be disabled STF
name name Specifies the name for a button STF
type button
reset
submit 
Specifies the type of button STF
value text Specifies the initial value for a button STF

5. Standard Attributes

The <button> tag supports the Standard Attributes in HTML.


6. Event Attributes

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


Relative articles