Course contentsShow
← Web Development
Lesson 104 of 2,9822. HTML FundamentalsFree lesson

The <button> Element and Types

Creating submit, reset, and button type buttons with proper semantic meaning.

The <button> Element and Types

You'll learn: How to create different types of buttons in forms and understand what each type does.

What Is a <button>?

A <button> is an interactive element users can click to perform actions. Unlike plain text or images, buttons are explicitly designed for interaction. Think of them like the buttons on a remote control—each one has a specific purpose, and you press them to make something happen.

The Three Button Types

Buttons come in three flavors, controlled by the type attribute:

1. Submit Button (type="submit") This is the default. When clicked, it submits the form data to the server—like pressing "Send" on an email.

<button type="submit">Submit Form</button>

2. Reset Button (type="reset") This clears all form inputs back to their original values—like an "undo all changes" button for your form.

<button type="reset">Clear Form</button>

3. Generic Button (type="button") This button does nothing on its own. It's meant for custom actions you'll program later with JavaScript. Think of it as a blank button waiting for instructions.

<button type="button">Click Me</button>

Why Types Matter

Using the correct type gives your button semantic meaning—it tells both the browser and users what the button will do. A submit button automatically knows to send form data. A reset button knows to clear inputs. This clarity improves usability and accessibility.

Inside a Form

<form>
  <label for="username">Username:</label>
  <input type="text" id="username" name="username">
  
  <button type="submit">Submit</button>
  <button type="reset">Reset</button>
</form>

Key Takeaway: The <button> element creates interactive buttons, and its type attribute (submit, reset, or button) defines its semantic purpose and default behavior within forms.