![]() |
VOOZH | about |
The <button> 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.
Syntax:
<button>Click Me!</button>The various attributes that can be used with the "button" tag are listed below:
Attributes | Descriptions |
|---|---|
Specifies whether the button should automatically get focus or not when the page loads | |
Indicate whether the element is disabled or not. If this attribute is set, the element is disabled. | |
Create a form for user input. There are many elements that> are used within the >form tag. | |
Specifies where to send the data of the form. | |
Specifies that the Input Element should not be validated when submitting the form. | |
Specifies that the form data should be encoded when submitted to the server. | |
Specifies the HTTP method used to send data while submitting the form. | |
Specifies the name or a keyword that indicates where to display the response after submitting the form. | |
Specifies the type of button for button elements. It is also used in <input> element to Specifies the type of input to display. | |
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.
A reset button resets all the form fields to their default values. It's created by setting the type attribute to reset inside the <button> tag.
An HTML Animated Button can be enhanced with various animations to make it visually engaging and interactive.
HTML Button Groups are used to group multiple buttons together, typically to create related actions or options. Button groups help maintain a clean and organized layout, especially when we have multiple buttons performing related tasks.
In HTML, the disabled attribute is used to make a button non-interactive, meaning users cannot click or interact with it. When a button is disabled, it visually appears inactive, and its functionality is prevented.
The <button> tag supports various event attributes that allow us to trigger actions in response to user interactions. Some of the commonly used event attributes are:
1.onclick: This event is triggered when the button is clicked.
<button onclick="alert('Button Clicked!')">Click Me!</button>2. onmouseover: This event is triggered when the user hovers over the button.
<button onmouseover="this.style.backgroundColor = 'yellow'">Hover Over Me!</button>3. onmouseout: This event is triggered when the mouse leaves the button.
<button onmouseout="this.style.backgroundColor = ''">Mouse Out Button</button>4. onfocus: This event is triggered when the button gains focus (e.g., clicked or tabbed into).
<button onfocus="this.style.backgroundColor = 'lightblue'">Focus Me!</button>5. onblur: This event is triggered when the button loses focus.
<button onblur="this.style.backgroundColor = ''">Blur Me!</button>Now you have clear understanding of HTML <button> so you can implement this knowledge to create some interesting components using CSS and JavaScript–
Note: The HTML <button> tag supports the Global Attribute and Event Attribute in HTML.