HTML Tutorial
The HTML <button>
tag creates a clickable button that can perform various actions, such as submitting a form, navigating to a new page, or triggering custom JavaScript code.
Key attributes of the <button>
tag include:
<button>Click Me</button>
<button onclick="alert('Hello World!')">Show Message</button>
Exploring the <button>
Tag
To demonstrate the <button>
tag, let's create a simple HTML example:
<!DOCTYPE html>
<html>
<head>
<title>Button Example</title>
</head>
<body>
<h1>Exploring the `<button>` Tag</h1>
<button type="button" onclick="alert('Button Clicked!')">Click Me</button>
</body>
</html>
In this example:
<button>
tag creates a clickable button with the text "Click Me".type
attribute is set to "button" (the default value).onclick
attribute triggers a JavaScript alert when the button is clicked.To make your buttons more accessible and user-friendly, consider the following:
Enter
key to submit a form).