The button tag in HTML is used to create a button in HTML. This button is a clickable button. You may have also seen a button getting created using input type. Well, using button tag allows you add images, which you cannot do with input type submit.
Following are the attributes −
Attribute | Value | Description |
---|---|---|
autofocus | autofocus | A button getting focus when the page loads |
disabled | disabled | Disable a button |
form | form_id | One or more forms the button belongs to |
formaction | URL | For type="submit". Where to send the form-data when a form is submitted. |
formenctype | application/x-www-form-urlencoded multipart/form-data text/plain | For type="submit". How form-data should be encoded before sending it to a server. |
formmethod | get post | For type="submit". How to send the form-data " |
formnovalidate | formnovalidate | For type="submit". The form-data should not be validated on submission. |
formtarget | _blank _self _parent _top framename | For type="submit". Where to display the response after submitting the form. |
name | name | Specifies a name for the button |
type | button reset submit | Specifies the type of button |
value | text | Specifies an initial value for the button |
Let us now see an example to implement button tag in HTML −
Example
<!DOCTYPE html> <html> <body> <h2>Demo Heading</h2> <p>We have added demo text below:<p> <textarea rows="4" cols="50"> Here, we are learning the concepts, elements and attributes in HTML! </textarea><br> <button type="button" disabled>Previous</button> <button type="button">Next</button> </body> </html>