Buttons in HTML

Buttons in HTML are used to perform actions such as submitting forms, resetting inputs, or running JavaScript functions. There are different ways to create buttons using HTML tags.

<button> Element

This is the most common and flexible way to create a button.

<button>Click Me</button>

<input> Element with type="button"

This creates a basic clickable button.

<input type="button" value="Click Me">

Submit Button

This submits a form when clicked.

<input type="submit" value="Submit">

Reset Button

This resets all form fields to their default values.

<input type="reset" value="Reset">

Using JavaScript with a Button

Buttons can run JavaScript code when clicked.

<button onclick="alert('Hello!')">Say Hello</button>