HTML - how to use <button> tag

The <button> tag defines a clickable button. This is similar to a input button element but is more powerful in terms of styling. The <button> tag allows styling of the content, for example, bold, italics and also supports images. Note that the type attribute should be set as different browsers have different default behavior.

Attributes

The address tag supports the global and event attributes.

autofocus
This indicates that the button will get focus by default when the page loads.
disabled
This indicates that the button is disabled.
form
This indicates the form element that this button relates to. The value should contain the id of the form.
formaction
This indicates the URL that processes the form when submitted. This works only when the type is set to "submit" and overrides the form's action attribute.
formenctype
This indicates that the encoing of the form data when type is set to "submit".
formmethod
When the type is set to "submit", this indicates how to send the form data. Allowed values are "get" and "post".
formnovalidate
This indicates that the form should not be validated when type is set to "submit".
formtarget
This indicates where to display the response obtained from the server when then form is submitted when type is set to "submit". Allowed values include:
  • _self:
  • _blank:
  • _parent:
  • _top:
name
This indicates a name for the button
type
This indicates the type of the button. Allowed values are "submit", "button" and "reset".
  • submit: the button will send data to the server.
  • button: no default behavior. Javascripts can be added to the button.
  • reset: the button will reset the form.
value
This indicates the initial value of the button

Examples:

<div> <button name="button" type="submit">Click <i>me</i></button> </div>