All subjects · Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript
HTML forms: structure, controls, input types and buttons
Edexcel IAL Information Technology · WIT12 3 hour practical exam on web development with HTML, CSS and JavaScript
Forms collect data from users. The specification lists form structure, elements, controls, buttons, grouping, input types, text areas and drop-down lists (spec 7.3.3).
A complete form
<form action="register.php" method="post">
<fieldset>
<legend>Your details</legend>
<label for="fname">First name</label>
<input type="text" id="fname" name="fname">
<label for="email">Email</label>
<input type="email" id="email" name="email">
<label for="age">Age</label>
<input type="number" id="age" name="age" value="18">
</fieldset>
<fieldset>
<legend>Membership</legend>
<input type="radio" id="adult" name="type" value="adult" checked>
<label for="adult">Adult</label>
<input type="radio" id="junior" name="type" value="junior">
<label for="junior">Junior</label>
<input type="checkbox" id="news" name="news">
<label for="news">Send me the newsletter</label>
<label for="centre">Centre</label>
<select id="centre" name="centre">
<option value="north">North</option>
<option value="south" selected>South</option>
</select>
<label for="notes">Anything else?</label>
<textarea id="notes" name="notes" rows="4" cols="40"></textarea>
</fieldset>
<button type="submit">Join</button>
<button type="reset">Clear</button>
</form>Structure and grouping
<form>contains the controls; action is where the data is sent and method is how (next lesson).<label>names a control. Its for attribute matches the control's id, so clicking the label focuses the control and screen readers announce the label. This is an accessibility requirement.<fieldset>groups related controls with a border, and<legend>gives the group a caption.- The name attribute is the name the data is sent under; without it, a control's value is not submitted.
- value sets the starting value (or the value sent for radio buttons, checkboxes and options).
Controls and input types
| Control | Use |
|---|---|
| `type="text"` | Single line of text |
| `type="email"` | Email address (checked for an @ and a domain; phones show an email keyboard) |
| `type="password"` | Text hidden as dots |
| `type="number"` | A number, with min, max and step |
| `type="date"` | A date picker |
| `type="tel"` | A phone number (phones show a keypad) |
| `type="url"` | A web address |
| `type="range"` | A slider between min and max |
| `type="radio"` | Choose **one** of a group: every radio in the group shares the same name |
| `type="checkbox"` | Tick any number of independent options |
| `type="color"` | A colour picker |
| `type="file"` | Upload a file |
| `type="hidden"` | A value sent with the form but not shown |
| `<textarea>` | Several lines of text; rows and cols set its size |
| `<select>` with `<option>` | A drop-down list; selected chooses the default option; multiple allows several |
| `<button type="submit">` or `<input type="submit">` | Sends the form |
| `<button type="reset">` | Puts every control back to its **starting** value (not necessarily empty) |
| `<button type="button">` | Does nothing by itself: used to run JavaScript |
Reset means 'back to the start'
Pearson's June 2025 examiner report noted that saying the form 'will reset' was not enough: candidates had to say what the value became. In the form above, after the user changes the age and clicks Clear, the age box goes back to 18, its value attribute, Adult is selected again and the centre returns to South.
Worked example
Write the HTML for a group of three radio buttons asking for a preferred session (Morning, Afternoon, Evening), with labels, where only one can be chosen and Morning is chosen at the start.
- Radio buttons in one group must share the same name, so give each name="session".
- Each needs a different value and an id that a label's for attribute matches.
- Add checked (a Boolean attribute, no value) to Morning.
Answer: ```html <input type="radio" id="morning" name="session" value="morning" checked> <label for="morning">Morning</label> <input type="radio" id="afternoon" name="session" value="afternoon"> <label for="afternoon">Afternoon</label> <input type="radio" id="evening" name="session" value="evening"> <label for="evening">Evening</label> ```
Check yourself
- Three radio buttons let a user choose one ticket type, but the user can select all three at once. What is the most likely cause?
- They do not have labels
- They do not share the same name attribute
- They are not inside a fieldset
- They do not have the checked attribute
Show answer
They do not share the same name attribute. Radio buttons form a group (one choice only) when they share the same name.
- How is a label connected to its input so that clicking the label focuses the input?
- The label's id matches the input's name
- The label's name matches the input's value
- The label is placed directly after the input
- The label's for attribute matches the input's id
Show answer
The label's for attribute matches the input's id. for on the label = id on the control.
- Which element should be used for a comment box where users type several lines? Type the element name.
Show answer
textarea. textarea is a multi-line text control.
- An input is `<input type="number" name="age" value="18">`. The user types 25 and then clicks a reset button. What does the age box show?
- 25
- It becomes empty
- 18
- 0
Show answer
18. Reset puts each control back to its starting value, which is set by the value attribute: 18.
- Which input type makes a phone display an email keyboard and checks the text contains an @?
- type="email"
- type="text"
- type="url"
- type="tel"
Show answer
type="email". type="email" gives a suitable keyboard and built-in format checking.
- Which pair of elements creates a drop-down list?
- `<list>` and `<item>`
- `<dropdown>` and `<choice>`
- `<select>` and `<option>`
- `<ul>` and `<li>`
Show answer
`<select>` and `<option>`. select contains option elements.
- What do the fieldset and legend elements do in a form?
Show answer
fieldset groups related form controls together, and legend gives that group a caption or title.. fieldset groups related controls (drawn with a border) and legend captions the group, which screen readers announce with each control.
- A form is submitted but the server receives nothing from one text box. Which attribute is most likely missing from that input?
- id
- name
- placeholder
- class
Show answer
name. Only controls with a name are included in the submitted data.
Sources
- Pearson Edexcel International Advanced Subsidiary/Advanced Level in Information Technology specification (first teaching 2018), Unit 2 Topics 7 to 11
- Pearson qualifications: Edexcel International Advanced Level Information Technology (2018)
- Pearson WIT12/01 examiner report, June 2025 series
Last updated 8 November 2026. Spotted a mistake? Tell us.