agyanadda@gmail.com

HTML Forms

HTML Forms 1 min read Updated Nov 30, 2026 Topic 26 of 33

Example

Example — A simple login form HTML
<form action="/login" method="post">
  <label for="email">Email</label><br>
  <input id="email" type="email" name="email" required><br><br>

  <label for="pass">Password</label><br>
  <input id="pass" type="password" name="password" required><br><br>

  <button type="submit">Log in</button>
</form>

method="post" sends data in the request body — always use it for passwords.

Try it Now »

Test Yourself With Exercises

Exercise 1 Multiple Choice

Which method should be used to send a password?

Exercise 2 Fill in the Blank

The address where form data is sent goes in the ___ attribute.

Exercise 3 True / False

Each input needs a name attribute for its value to be sent.

Frequently Asked Questions

GET adds the data to the URL (good for search forms). POST sends it hidden in the request (use it for logins, sign-ups and payments).