Web4College

HTML button tag

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

Example
Try it
<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>
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.

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

disabled attribute makes the button unclickable.

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

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

Example
Try it
<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.

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

formmethod attribute specifies the HTTP method for the form submission.

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

formtarget attribute represents the browsing mode to submit the form.

Example
Try it
<button type="button" name="button" formmethod="post"> Send </button>
name

name attribute specifies a unique name for the button.

Example
Try it
<button type="reset" name="reset"> reset </button>
type

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

Example
Try it
<button type="reset" name="reset"> reset </button>
value

value attribute labels the button element by its content.

Example
Try it
<button type="submit" name="button" value="submit"></button>