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>
 </form>
Try </>
Name:
Email:

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

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

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

disabled attribute makes the button unclickable.

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

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

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

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

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

formmethod attribute specifies the HTTP method for the form submission.

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

formtarget attribute represents the browsing mode to submit the form.

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

name attribute specifies a unique name for the button.

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

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

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

value attribute labels the button element by its content.

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


Was this article helpful?