HTML Dog
Skip to navigation

HTML Tag: button

Button form control that contains, and is labelled by, content.

Optional Attributes

Attribute Description Possible values
name Name of the form control, to be paired with its value. Text (no spaces).
type The type of button.
  • submit (default): Submits the form.
  • reset: Resets the controls in a form to their initial default values.
  • button: Does nothing by itself — typically used in conjunction with JavaScript.
value Used when type is submit. The button’s value, sent when the button is used to submit its associated form. Text.
disabled Disables the form control. None.
autofocus Indicates that the form control should have focus on page load. Should only be used on one form control in a page. None.
form Explicitly associates the control to a form element, which it may or may not be nested within. If absent, the control will be associated to its form ancestor. Text matching the value of a form element’s id attribute.
formaction Used when type is submit. The address to which submitted form data should be sent to. Will override a form element’s action attribute. URL.
formmethod Used when type is submit. The HTTP method by which submitted form data should be sent. Will override a form element’s method attribute.
  • get: Bolts the form values onto the URL that the form is submitted to. Used for simple data sending, such as search queries, for example.
  • post: Invisibly sends the form data in the body of the submitted HTTP request. Used for more detailed or secure data sending, such as contact forms, for example.
formenctype Used when type is submit. The MIME type used to encode the form data. Will override a form element’s enctype attribute.
  • application/x-www-form-urlencoded: Default.
  • text/plain: Basic text.
formnovalidate Used when type is submit. Indicates that the form should not be validated before it is submitted. Will override a form element’s novalidate attribute. None.
formtarget Used when type is submit. The browsing context in which the submitted form’s destination URL should open. Will override a form element’s target attribute.
  • _self: Opens in current window / tab.
  • _blank: Opens in a new window / tab.
Global attributes

Example


<button>Push my <strong>button</strong>, baby</button>