▶ TrainingGet Pro
All tools & lessonsAll toolsAllGet the appApp
Learning departments Music, Math, Cookery, Programming and Art are open – explore →

HTML and CSS lesson 15: Flexbox: boxes in a row

US version. US grades and US spelling. · UK version of this lesson

display: flex on a container lines up the boxes inside it in a row; flex-direction: column stacks them and gap sets the space between. A complete 40-minute HTML and CSS lesson for beginners (Grades 6–7), from Unit 5: Boxes and layout. 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.

  1. Read what your child will learn together.
  2. 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.
  3. 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.
  4. Finish with the exit questions and the talk question: “Where have you seen boxes in a row on websites you use?”
  5. Later that day or the next day: the homework (20 minutes), then a practice test.

Watch out for

  • display: flex goes on each box. It goes on the parent that holds them.
  • gap adds space at the edges too. Only between items.

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: put boxes in a row with flexbox.

Success looks like

  • I can put boxes in a row with flexbox.
  • I can stack them in a column.
  • I can set the space between items with gap.

Key words

flexbox · flex container · flex item · flex-direction · row · column · gap

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)

Normally blocks such as <div> stack one under another. Flexbox changes that: put display: flex; on the CONTAINER (the parent) and the boxes inside it line up side by side in a row.

flex-direction: column; turns the row into a column. gap: 20px; puts 20px between the items – but not at the edges. A menu bar is a classic use: nav { display: flex; gap: 16px; } puts the links in a row.

The most common mistake is putting display: flex on the items instead of the container. Another is a misspelt value: display: flexbox or flex-direction: columns are ignored, so nothing changes.

Worked example: a menu bar

CSS:

nav { display: flex; gap: 16px; }

HTML:

<nav>
<a href="index.html">Home</a>
<a href="news.html">News</a>
<a href="contact.html">Contact</a>
</nav>

The lesson, step by step

40 minutes in 5 parts
PartTimeHow it is checked
Starter5 minGraded by Classfern
Learn8 minRead, watch and talk
See it7 minGraded by Classfern
Practice15 minGraded by Classfern
Check and reflect5 minGraded 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

All computer science practice tests · All 20 HTML and CSS lessons

Curriculum

CSTA K–12 Computer Science Standards (2017), grades 6–8: 2-AP-13 – Decompose problems to help design, implement and review programs.

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.