Computer >> Computer tutorials >  >> Programming >> HTML

How do we add a push button to HTML?


Use the <button> tag in HTML to add a push button. The HTML <button> tag is used for creating a button within HTML form. You can also use <input> tag to create similar buttons.

The following are the attributes of the <button> tag −

Attribute
Value
Description
autofocusHow do we add a push button to HTML?
Autofocus
Specifies that the button should have input focus when the page loads.
disabledHow do we add a push button to HTML?
Disabled
Specifies the button is disabled.
formHow do we add a push button to HTML?
form_id
Specifies the forms to which button belongs.
formactionHow do we add a push button to HTML?
URL
Specifies the link where the form submits.
formenctypeHow do we add a push button to HTML?
application multipart/form-data text/plain
Specifies how the form data is encoded before sending it to server.
formmethodHow do we add a push button to HTML?
get
 post
Specifies how to send form data.
formnovalidateHow do we add a push button to HTML?
Formnovalidate
Specifies that the form data should not be validated.
formtargetHow do we add a push button to HTML?
_blank
_self
 _parent
 _top
Specifies where the response should be validated.
Name
Name
Specifies the button name.
Type
button
reset
submit
Specifies the button type.
Value
Text
Specifies button's initial value.

Example

You can try to run the following code to implement <button> tag in HTML −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Button Tag</title>
   </head>
   <body>
      <form>
         <button name = "button" value = "OK" type = "button">My Button</button>
      </form>
   </body>
</html>