html · level 2 · unit 1 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Every needs a name, or its answer is never sent.
Each question on a form is a field: a label and a box. When someone presses the button, the browser packs up the answers and sends them to a , the computer that stores the website and reads its forms.
The browser only sends answers that have a name. Each one travels as a pair, like email=sam@example.com. The label is for people. The name is for the server.
On the <form> tag, action gives the address that receives the answers. method="post" sends them tucked out of sight, instead of in the address bar.
<form action="https://example.com/join" method="post">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<button>Join</button>
</form> Press show my page to see it here.
id joins the label to its box, and name labels the answer for the server. They are often the same word.
guess first
Which answer will reach the server?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
<form action="https://example.com/order" method="post">
<label for="pizza">Pizza</label>
<input id="pizza" name="pizza">
<label for="drink">Drink</label>
<input id="drink">
<button>Order</button>
</form>
your turn
Your turn. Get a sign-up form ready to send.
Send the form to https://example.com/signup using post, and give the box the name username.
Press show my page to see it here.
- the form goes to the sign-up addressnot checked yet
- the form uses postnot checked yet
- the box is named usernamenot checked yet
fix it
The bakery keeps getting empty orders. Can you fix it?
Press show my page to see it here.
- the box has a namenot checked yet
- no misspelt attributes are leftnot checked yet
- The box looks fine, but its answer never arrives. Read each attribute on line 3 slowly.
- The browser ignores attributes it does not know, and one of them is misspelt.
- Change
nmaetoname, then press run.
nailed it
your answers now reach the server. :D
- Only fields with a
nameare sent. actionsays where the answers go.method="post"keeps answers out of the address bar.
new words in your collection
- field
- server
This lesson isn’t saved. A free account remembers every lesson you finish.