Loading...
HTML <button> Tag

HTML <button> Tag

In this tutorial, we will learn about button tag in HTML with the help of examples.


<button> Tag

Button tag <button> tag is used for creating a button within HTML form.

We must have to specify the type attribute for the <button> tag to know the type of button used.

Note : We can also use <input> tag to create similar buttons. but we are not able to use tags like <i>, <br>, <strong>, <img> etc. inside button created by using <input> tag.

Syntax

<button>.....</button>

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Button Tag</title>
  </head>
  <body>
    <button value = "Click me" type = "button">Click me</button>
  </body>
</html>

Output


Specific Attribute

Attribute Value Description
autofocus autofocus Specifies that the button should have input focus when the page loads
disable disable Specifies that the button is disable
form form_id specifies the form to which the button belongs
formaction URL Specifies the link where the form submits on the clicking of the button
formenctype application multipart/ data text/plain Specifies that the button should have input focus when the page loads
formmethod get
post
Specifies how to send form data to the server
formnovalidate formnovalidate Specifies that the form data should not be validated
formtarget _blank
_parent
_self
_top
Specifies where to open the target URL
_blank = the target URL will open in a new window.
_self = the target URL will open in the same frame as it was clicked.
_parent = the target URL will open in the parent frameset.
_top = the target URL will open in the full body of the window
name name Specifies the name of the button
type type Specifies the type of the button
value text Specifies button initial value

Global Attribute

Button Tag support all the global attributes of HTML.


Event Attribute

Button Tag support all the event attributes of HTML.


Next Tutorial

We hope that this tutorial helped you develop better understanding of the concept of button tag in HTML.

Keep Learning : )

In the next tutorial, you'll learn about HTML canvas Tag.

- Related Topics