HTML button tag

HTML <button> tag defines a button labeled by its content. Various properties make a button more useable.

<form action="files/buttontag.php" method="post">
  Name:<input type="text" name="userName"><br>
  Email:<input type="email" name="email"><br>
  <button name="submit">submit</button>
Try </>

Tag Uses

Specific uses of <button> tag

It is used to submit, save and reset the data.

Tag omission

Both starting and ending tags are necessary for the button element.

Global Attributes

All the global attributes are applicable on the button element.

Tag Attributes

Attributes that are applicable to <button> tag

autofocus attribute focuses the cursor on the respective input control after the page is loaded.

<button type="submit" name="submit" autofocus>Submit</button>

disabled attribute makes the button unclickable.

<button type="submit" name="submit" disabled>Submit</button>

form attribute associates the input control to the respective form element.

<button type="submit" name="submit" form="id of form element">Submit</button>

formenctype attribute specifies the type of encoding used for the form submission.

<button type="button" name="button" formenctype="text/html"> Send </button>

formmethod attribute specifies the HTTP method for the form submission.

<button type="button" name="button" formmethod="post"> Send </button>

formtarget attribute represents the browsing mode to submit the form.

<button type="button" name="button" formmethod="post"> Send </button>

name attribute specifies a unique name for the button.

<button type="reset" name="reset"> reset </button>

type attribute specifies the type of button. The type may be a submit, reset and button.

<button type="reset" name="reset"> reset </button>

value attribute labels the button element by its content.

<button type="submit" name="button" value="submit"></button>

Was this article helpful?