Skip to main content

<button> - Button

The button element is an element that can be used to display a clickable button in a web page. It can be defined by using a pair of <button> and </button> tag.

You can use button to:

  • Create a link that displayed as a button. You need to put the button tag as the text value of an <a> tag.
  • Create a trigger for submitting data contained in one or more elements within a <form> tag.
  • Create a trigger for invoking JavaScript code that defined as value of <script> tag.

Possible Attributes

  • id: Unique identifier of the element in the HTML page. It is usually used as unique reference to the element in a JavaScript code.
  • name: Name of the button. It is used to give text label to the associated value when the tag is defined in a <form> tag.
  • value: A value represented by the button when the tag is defined in a <form> tag. It is usually contain the data that may be submitted to the backend.
  • disabled: A boolean flag that determines whether the button is disabled, i.e. clickable by the user.
  • onclick: Contains a JavaScript code that will be executed whenever the button is clicked.

Usage Example

Loading Code Editor...

Output: