HTML Button Tag (original) (raw)
Last Updated : 23 May, 2026
The tag in HTML is used to create clickable buttons on a webpage. These buttons can trigger various actions, such as submitting a form, running JavaScript functions, or simply interacting with users.
- **Versatile Content: The tag can contain text, images, or other HTML elements.
- **Form Integration: Can be used inside forms to submit or reset data.
- **Event Handling: Supports event attributes like onclick, onmouseover, and onfocus for interactive actions.
- **Customizable Styles: Easily styled with CSS, including properties like border-radius, box-shadow, and animations.
**Syntax:
Click Me!
- The opening tag marks the start of the button element.
- The closing tag indicates the end of the button element.
- The text Click Me! will be displayed on the button. HTML `
`
- The HTML creates a simple button with the text "Click Me!".
- The button changes its background color when hovered over.
Attributes
The various attributes that can be used with the "button" tag are listed below:
| Attributes | Descriptions |
|---|---|
| autofocus | Specifies whether the button should automatically get focus or not when the page loads |
| disabled | Indicate whether the element is disabled or not. If this attribute is set, the element is disabled. |
| form | Create a form for user input. There are many elements that> are used within the >form tag. |
| formaction | Specifies where to send the data of the form. |
| formnovalidate | Specifies that the Input Element should not be validated when submitting the form. |
| formenctype | Specifies that the form data should be encoded when submitted to the server. |
| formmethod | Specifies the HTTP method used to send data while submitting the form. |
| formtarget | Specifies the name or a keyword that indicates where to display the response after submitting the form. |
| type | Specifies the type of button for button elements. It is also used in element to Specifies the type of input to display. |
| value | Specifies the value of the element with which it is used. It has different meanings for different HTML elements. |
**Note: It is important to specify the type attribute for a button element to inform the browser of the button's function.
Reset Button
A reset button resets all the form fields to their default values. It's created by setting the type attribute to reset inside the tag.
HTML `
Centered Reset Button Example