Flexbox container, online

Six activities your students do on their own devices. See who's finished, and their scores.

Flexbox container in one minute

What students need to know

display: flex on section makes it a flex container. flex-direction: column makes its children stack vertically. Without flex-wrap: wrap, items stay on one line and may overflow. wrap lets them break onto a new row or column.

display: flex is the correct value. 'flexbox' is not valid — the property value is simply 'flex'. justify-content controls alignment along the main axis. align-items controls alignment along the cross axis.

Mistakes students make

  • CSS declarations require a colon. It should be display: flex; not display flex;.
  • 'rows' is not a valid value. The correct value is flex-direction: row; (singular).
  • CSS property names must be lowercase. 'Flex-wrap' should be written as 'flex-wrap'.
  • 'centre' is not a valid value. CSS uses American English spelling: justify-content: center;.
PREVIOUS · MODULE 52Positioning
YOU ARE HERE · MODULE 53Flexbox container
NEXT · MODULE 54Flexbox alignment

Discover other journeys with this module

What students will learn in this module

Every question in Module 53

Quick questions

  1. Which CSS declaration turns an element into a flex container?Adisplay: flexboxBdisplay: flex
  2. What does flex-direction: column do?ALays flex items out vertically (top to bottom)BLays flex items out horizontally (left to right)
  3. What does flex-wrap: wrap do?AAllows items to move onto new lines when they run out of spaceBPrevents items from ever wrapping
  4. Which property aligns flex items along the main axis?Aalign-itemsBjustify-content
  5. True or false: align-items: center centres items along the main axis.AFalseBTrue

Key terms

Students type the meaning of:

  • display: flex

Match the pairs

nav {
  display: flex;
  flex-direction: row;
  gap: 16px;
}
Match it to what it does
div {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
Match it to what it does
display: flex turns an element into a flex container — its direct children become flex itemsMatch it to what it does
flex-wrap: wrap allows flex items to flow onto new lines when space runs outMatch it to what it does
nav { display: flexbox; }Match it to what it does
div { justify-content: centre; }Match it to what it does

Fill in the blanks

  1. nav { display: ____; }

    Hint: Type the display value that turns an element into a flex container

  2. div { ______________: row; }

    Hint: Type the flexbox property name that sets the main axis direction

  3. div { flex-direction: ___; }

    Hint: Type the flex-direction value that lays items out horizontally left to right

  4. nav { display: flex; _________: wrap; }

    Hint: Type the flexbox property name that controls whether items wrap onto multiple lines

  5. nav { _______________: center; }

    Hint: Type the flexbox property name that aligns items along the main axis

Spot the error

Question 1

Anav { display flex; }Bdiv { flex-direction: row; }Cp { flex-wrap: wrap; }

Question 2

Anav { display: flex; }Bdiv { flex-direction: rows; }Csection { flex-wrap: wrap; }

Question 3

Anav { display: flex; }Bdiv { flex-direction: row; }Csection { Flex-wrap: wrap; }

Question 4

Anav { display: flex; }Bdiv { flex-direction: row; }Csection { flex-wrap: wrap; }Dp { justify-content: centre; }

Question 5

Anav { display: flex; }Bdiv { flex-direction: column; }Csection { flex-wrap: wrap; }Dheader { justify-content: center; }Efooter { align-items: streetch; }