Menu
Coddy logo textTech

Buttons in Forms

Part of the Fundamentals section of Coddy's HTML journey — lesson 45 of 60.

Buttons play a key role in forms, where they help submit data or reset fields. Let’s see how they work:

Submit Button:

<form>
	<input type="text" name="username" placeholder="Enter username">
	<button type="submit">Submit</button>
</form>
  • type="submit": Sends the form data to the server.

Reset Button:

<form>
	<input type="text" name="name" value="John Doe">
	<button type="reset">Reset</button>
</form>
  • type="reset": Clears all fields and resets them to their default values.
challenge icon

Challenge

Easy

Create an HTML document that includes a form with different types of buttons. The form should have the following elements:

  1. A text input field with the name "message" and a placeholder that says "Enter your message".
  2. Add a submit button (<button type="submit">) with the text "Send".
  3. Add a reset button (<button type="reset">) with the text "Clear".
  4. Add a generic button (<button>) with the text "Click Me".

Cheat sheet

Buttons in forms have different types for specific functions:

Submit Button:

<button type="submit">Submit</button>
  • type="submit": Sends the form data to the server

Reset Button:

<button type="reset">Reset</button>
  • type="reset": Clears all fields and resets them to their default values

Generic Button:

<button>Click Me</button>
  • Default button without specific form behavior

Try it yourself

<!DOCTYPE html>
<html>
    <body>
        <!-- Write code here -->
    </body>
</html>
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals