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
autofocus
Autofocus
Specifies that the button should have input focus when the page loads.
disabled
Disabled
Specifies the button is disabled.
form
form_id
Specifies the forms to which button belongs.
formaction
URL
Specifies the link where the form submits.
formenctype
application multipart/form-data text/plain
Specifies how the form data is encoded before sending it to server.
formmethod
get
 post
Specifies how to send form data.
formnovalidate
Formnovalidate
Specifies that the form data should not be validated.
formtarget
_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>

Updated on: 24-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements