YOUMenuexample.com/menu.htmlexample.com/order?drink=Flat+white&cups=2example.com/orderDrinkFlat whiteCups2Order!Please fill out this field.1<form action="/order"><form action="/order" method="post">2<label for="drink">Drink</label>3<input id="drink" name="drink" required>4<label for="cups">Cups</label>5<input id="cups" name="cups" type="number">6<button>Order</button>7</form>example.com /orderdrinkcups<label><input><input><button>Flat white2Drink, required
Front left: the form's HTML, one line per partBack right: the browser, which draws the controls, checks them and sends themChips and envelopes: tags, typed values and the name=value pairs on their wayFront left: menu.html, a seven-line form on a card. Back left: you, the visitor. Back right: a web browser. Front right: the server at example.com, with a cell for each value it reads. As each line is read, a tag chip hops to the control it becomes. Clicking Order with Drink empty shows a message and sends nothing; after typing, an envelope carries drink=Flat+white&cups=2 to the server and the address bar shows it. After a real submit the browser loads whatever page the server sends back, such as "Thanks for your order". The figure keeps the form in view so you can see the parts.

Fields with names

  1. A form collects what a visitor types and sends it to a server. The <form> element wraps the fields, and its action attribute, /order, says where the answers go. The form itself draws nothing: only its fields appear.

Checking and sending

Method and meaning

What happens

;; step 1/11 · form
line 1   <form action="/order">
line 7   </form>
form     groups the fields between them
action   "/order": the address the answers go to
method   none given, so the default: GET
drawn    nothing (a form has no box of its own)

The seven lines are a working page: save them as menu.html and open it. A full page would also start with <!DOCTYPE html> and have html, head and body tags, which the browser adds when they are missing. After a real submit the browser loads whatever page the server sends back, such as "Thanks for your order". The figure keeps the form in view so you can see the parts.