Buttons

All About HTML Buttons

Buttons in HTML are essential interactive elements that enable users to submit forms, trigger actions, and navigate between pages. Buttons can be created using the <button></button> element or the <input> element with specific types. They can be styled and customized to enhance user experience.

The standard <button></button> element creates a clickable button that can contain text, images, or other elements.

Code

<button>Click Me</button>

Result

Within forms you can add a button to submit them in two different ways.

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

Or a button to reset the form entirely.

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

The common button attributes are:

  • type defines the button's behaviour and can take the values of button, submit, or reset.
  • disabled makes a button be disabled by default. This can be useful when combining with JavaScript to enable the button once certain criteria have been met.
    <button disabled>Disabled Button</button>