Advertisement

HTML <button> tag

Examples

The following code marking a button:

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

Try it yourself

Browser Support

IE Firefox Chrome Safari Opera

All major browsers support <button> tag.

Important: If you use the button element in an HTML form, different browsers will submit different values. Internet Explorer will submit the text <button> and <button /> between, while other browsers will submit the content value of the property. Please use the HTML form input elements to create a button.

Definition and Usage

<Button> tag defines a button.

Internally button element you can put content, such as text or images. This is different from the button element and the input element created between.

<Button> control with the <input type = "button">, compared with a more powerful and richer content. <Button> and </ button> tags all content between the buttons are content, including any acceptable text content, such as text or multimedia content. For example, we can include an image and associated text in the button, create an attractive image tags use them in the button.

The only elements of the prohibited image map because of its mouse and keyboard actions would interfere with sensitive form button behavior.

Always provisions for the button type attribute. Internet Explorer is the default type "button", while other browsers default values ​​(including the W3C specification) is "submit".

HTML 4.01 and HTML 5 differences between

HTML 5 New property: autofocus, form, formaction, formenctype, formmethod, formnovalidate and formtarget.

Tips and Notes

NOTE: If you use the button element in an HTML form, different browsers will submit different values button. Use the input element to create buttons in an HTML form.

Attributes

new: HTML5 new property.

Attributes value description
autofocus autofocus When the page is loaded button provisions should automatically get focus.
disabled disabled Provisions should disable the button.
form form_name Provisions buttons belong to one or more forms.
formaction url

Covering the action attribute of the form element.

Note: This attribute type = "submit" used in conjunction.

formenctype See note

Covering enctype attribute form elements.

Note: This attribute type = "submit" used in conjunction.

formmethod
  • get
  • post

Cover method attribute of the form element.

Note: This attribute type = "submit" used in conjunction.

formnovalidate formnovalidate

Covering novalidate attribute form elements.

Note: This attribute type = "submit" used in conjunction.

formtarget
  • _blank
  • _self
  • _parent
  • _top
  • framename

Coverage target attribute form elements.

Note: This attribute type = "submit" used in conjunction.

name button_name Specifies the name of the button.
type
  • button
  • reset
  • submit
Provisions button type.
value text Predetermined initial value of the button. You can modify the script.

Note: formenctype property possible values:

  • application / x-www-form-urlencoded
  • multipart / form-data
  • text / plain

Global Properties

<button> tag supports HTML in the global properties .

Event Properties

<button> tag supports HTML in the event properties .

Related Pages

HTML DOM Reference Manual: the Button objects