HTML and CSS lesson 8: Forms: labels and text boxes
US version. US grades and US spelling. · UK 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 (Grades 6–7), from Unit 3: Forms. You build real web pages right here in your browser – nothing to install.
- Time
- 40 minutes + 20 min homework
- Grade
- Grades 6–7 (ages 11–12)
- You need
- A computer or tablet, paper and a pencil
- Graded
- 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 grades 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 color, a size – and predict what will happen before they look. Predicting first is how programmers learn fastest.
What your child will learn
Learning goal: make a form with labeled text boxes.
Success looks like
- I can make a form with labeled 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 labeled 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 | Graded by Classfern |
| Learn | 8 min | Read, watch and talk |
| See it | 7 min | Graded by Classfern |
| Practice | 15 min | Graded by Classfern |
| Check and reflect | 5 min | Graded 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 graded instantly.
Practice tests
- HTML forms test12 questions · graded instantly
- Mixed HTML and CSS test20 questions · graded instantly
- Mixed HTML and CSS test20 questions · graded instantly
All computer science practice tests · All 20 HTML and CSS lessons
Curriculum
CSTA K–12 Computer Science Standards (2017), grades 6–8: 2-CS-01 – Suggest device design improvements based on how users interact with them; 2-IC-23 – Describe trade-offs between making information public and keeping it private and secure.
The standard codes are CSTA's; the descriptions are our own words.
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.