HTML and CSS lesson 8: Forms: labels and text boxes
UK version. UK school years and UK spelling. · US version of this lesson
Forms collect answers: a <form> holds boxes (<input>) and a button. Every box needs a <label> whose for matches the box's id. A complete 40-minute HTML and CSS lesson for beginners (Year 7, KS3), from Unit 3: Forms. You build real web pages right here in your browser – nothing to install.
- Time
- 40 minutes + 20 min homework
- Year
- Year 7, KS3 (ages 11–12)
- You need
- A computer or tablet, paper and a pencil
- Marked
- Instantly, with explanations
For parents: how to use this lesson
You don't need to know HTML yourself. The lesson explains each step on screen, the way Mr Babbage, our Head of Computing, likes it: a worked example first, then a go for your child. When your child builds a page, the browser draws it straight away and Classfern marks it with a checklist.
- Read what your child will learn together.
- Press Start the lesson below. Sit with your child for the teaching and the worked example (about 15 minutes): ask them to point at each tag and say what it does.
- Let them do the practice on their own. If a page doesn't look right, the checklist says what is missing – let them find the mistake before you help.
- Finish with the exit questions and the talk question: “Which information should you never type into a website you don't trust?”
- Later that day or the next day: the homework (20 minutes), then a practice test.
Watch out for
formatches the box'sname.formatches the box'sid.- A misspelt type gives an error. It silently becomes a plain text box.
Miss Lovelace's tip for home: ask your child to change one thing on their page – a word, a colour, a size – and predict what will happen before they look. Predicting first is how programmers learn fastest.
What your child will learn
We are learning to make a form with labelled text boxes.
Success looks like
- I can make a form with labelled text boxes.
- I can join a label to its box with
forandid. - I can choose the right
typefor a box.
Key words
form · input · label · for · id · type · button · required
What to have ready
- A device with a web browser (pages are built and checked right in the browser – nothing to install)
- Paper for planning and sketching
- A keyboard helps for typing code (a tablet works too)
The big ideas (for the adult)
A form is a <form> element holding boxes and a <button>. The most common box is <input type="text">. Other types help the visitor: type="email", type="number" and type="password" each change how the box behaves (on a phone, email shows an @ key).
Every box needs a label. <label for="town">Town</label> is joined to <input id="town"> because for matches id exactly. Then clicking the words puts the cursor in the box, and screen readers read the label out. Words in a <p> next to a box are NOT a label.
Stay safe: a practice page should never ask for your real name, address, phone number or password. Our forms ask for harmless things like a nickname or a hobby, and nothing is sent anywhere.
Worked example: a labelled form
<form> <label for="nick">Nickname</label> <input type="text" id="nick" name="nick"> <button type="submit">Join</button> </form>
The lesson, step by step
| Part | Time | How it is checked |
|---|---|---|
| Starter | 5 min | Marked by Classfern |
| Learn | 8 min | Read, watch and talk |
| See it | 7 min | Marked by Classfern |
| Practise | 15 min | Marked by Classfern |
| Check and reflect | 5 min | Marked by Classfern + self-check |
The lesson
It runs here on the page. No sign-up and no names – nothing you type is sent anywhere. Each visit picks a new mix of questions.
Homework
20 minutes: predict what the browser will do, build or fix a short page, and check the key ideas – then a short reflection. New questions every time, all marked instantly.
Practice tests
- HTML forms test12 questions · marked instantly
- Mixed HTML and CSS test20 questions · marked instantly
- Mixed HTML and CSS test20 questions · marked instantly
All KS3 computing practice tests · All 20 HTML and CSS lessons
Curriculum
National curriculum in England, computing, key stage 3: pupils should be taught to use 2 or more programming languages, at least one of which is textual, to solve a variety of computational problems; make appropriate use of data structures [for example, lists, tables or arrays]; design and develop modular programs that use procedures or functions; and to understand a range of ways to use technology safely, respectfully, responsibly and securely, including protecting their online identity and privacy; recognise inappropriate content, contact and conduct, and know how to report concerns.
Contains public sector information licensed under the Open Government Licence v3.0.
Our lessons and questions are our own. They are not written or endorsed by any government department, testing agency or exam board. HTML and CSS are open web standards; Classfern is not affiliated with the organisations that publish them.