Creating A Button With The HTML Button Element: Here’s How
Element ofHTML Web Forms Tutorial For Coding BeginnersWhat does Creating A Button With The HTML Button Element: Here's How do?The <button> element is used to create an HTML button. Any text appearing between the opening and closing tags will appear as text on the button. No action takes place by default when a button is clicked. Actions must be added to buttons using JavaScript or by associating the button with a form.Displayinline
Code Example
<button type="button" onclick="alert('You pressed the button!')">Click me!</button>
Browser Support for button
All
All
All
All
All
All
Attributes of button
Attribute name
Values
Notes
type
Specifies the type of the button.
onClick
Runs a script when a button is clicked.
name
Defines the name of the button, which is used for form inputs and labels.
value
Sets the initial value of the button element.
disabled
Disables the button. It cannot be clicked and usually appears gray.
<button accesskey=””>
Defines an keyboard shortcut for the button. As of HTML5, this is a global attribute that can be used on any element.
tabindex
Determines the order of selection when the tab key is used.