freecourses.digital
Lesson progress: 0 of 3 activities done
All lessons in HTML Basics for Beginners Lesson 7.1 of 34

Module 10: Practice Project and Validation

  1. 10.1Build a simple HTML website

Understanding HTML forms

Inside this lesson

  • What a form does
  • The <form> element, action, and method
  • GET vs POST
  • Why every field needs a name

Short answer

An HTML form collects input from visitors, like an inquiry, an order, or a search. The <form> element wraps the fields. Its action says where to send the data and its method says how: GET for searches, POST for messages and orders. Each field needs a name, or its value is not sent.

What forms do

  • Contact and inquiry forms
  • Order and booking forms
  • Search boxes
  • Newsletter signups
  • Login pages

HTML builds the form. A server or form service receives and processes the data. HTML alone cannot send emails or save data.

The form element

<form action="/send-inquiry" method="post">
  <label for="name">Your name</label>
  <input type="text" id="name" name="customer_name">
  <button type="submit">Send inquiry</button>
</form>
  • action: the URL that receives the data.
  • method: get or post.
  • name: the label the server sees, like customer_name=Ana.

GET vs POST

GETPOST
Where data goesIn the URL: ?q=pili+tartsIn the request body, not the URL
Good forSearches and filtersMessages, orders, logins
Bookmarkable?YesNo
Safe for passwords?NoYes, with HTTPS

How submission works

  1. The visitor fills in the fields and clicks the submit button.
  2. The browser checks built-in rules, like required fields.
  3. The browser sends name and value pairs to the action URL.
  4. The server processes the data and returns a thank you page.

If you do not have a server, form services like Formspree, Netlify Forms, or Google Forms can receive submissions for you.

Try it: make a search form

Set method to get, give the input a name of q, and press the button. The preview is sandboxed, so the submit will not go anywhere. Check the code.

Live preview

Quick quiz

1. Which attribute says where form data goes?
2. Which method fits a search form?
3. A field without name is?
4. Can HTML alone send an email from a form?

Common mistakes

  • Missing name attributes. The server receives nothing for that field.
  • GET for private data. GET puts values in the URL, history, and logs.
  • Forms with no thank you message. Visitors are not sure their message was sent.

Your action

Tick each item when you can do it. Your progress saves on this device.

Key terms

<form>
The container for form controls.
action
The URL that receives form data.
method
How data is sent: get or post.
name attribute
The key sent with a field's value.
GET
Sends form data in the URL.
POST
Sends form data in the request body.

Questions beginners ask

Can I use a form on a static site?

Yes, with a form service like Formspree or Netlify Forms.

Is a Google Form an HTML form?

Google builds it with HTML, and you can embed it with an iframe.

What is form spam?

Bots submit junk. Services add spam filters and honeypot fields.

Related lessons

Need a website built or fixed while you practice? The team at Remar Digital can help.