Flexbox alignment, online

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

Flexbox alignment in one minute

What students need to know

justify-content: center pushes all flex items to the centre of the main axis (horizontally for flex-direction: row). space-between places equal gaps between items only. space-around adds equal gaps on each side of every item, including at the edges.

CSS uses American English. The correct value is 'center', not 'centre'. Using 'centre' will be silently ignored.

Mistakes students make

  • CSS declarations require a colon. It should be justify-content: center; not justify-content centre;.
  • 'middle' is not a valid align-items value. Use align-items: center; to centre items on the cross axis.
  • CSS property names must be lowercase. 'Align-items' should be written as 'align-items'.
  • 'stretchy' is not a valid value. The correct value is align-content: stretch;.

Discover other journeys with this module

What students will learn in this module

Every question in Module 54

Quick questions

  1. Which property aligns flex items along the main axis?Aalign-itemsBjustify-content
  2. What does align-items: center do?ACentres items along the cross axisBCentres items along the main axis
  3. Which justify-content value puts equal gaps between items with no space at the outer edges?Aspace-betweenBspace-around
  4. True or false: align-self overrides align-items for a single flex item.ATrueBFalse
  5. True or false: align-items: stretch is the default value.AFalseBTrue

Key terms

Students type the meaning of:

  • align-items

Match the pairs

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
Match it to what it does
.card { align-self: flex-end; }Match it to what it does
justify-content controls spacing and alignment along the main axisMatch it to what it does
align-items aligns all flex items on the cross axis — overridden per item by align-selfMatch it to what it does
div { align-items: middle; }Match it to what it does
div { justify-content: centre; }Match it to what it does

Fill in the blanks

  1. nav { display: flex; ___________: center; }

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

  2. div { display: flex; align-items: ______; }

    Hint: Type the alignment value that centres flex items on the cross axis

  3. nav { _______________: space-between; }

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

  4. div { __________: flex-end; }

    Hint: Type the flexbox property name that overrides align-items for a single flex item

  5. nav { justify-content: _____________; }

    Hint: Type the justify-content value that puts equal space between items with none at the edges

Spot the error

Question 1

Anav { justify-content centre; }Bdiv { align-items: center; }Csection { display: flex; }

Question 2

Anav { display: flex; }Bdiv { align-items: middle; }Csection { justify-content: center; }

Question 3

Anav { display: flex; }Bdiv { justify-content: space-between; }Csection { Align-items: center; }

Question 4

Anav { display: flex; }Bdiv { align-items: flex-start; }Csection { justify-content: center; }Dheader { align-content: stretchy; }

Question 5

Anav { display: flex; }Bdiv { align-items: center; }Csection { justify-content: flex-start; }Dheader { align-content: space-between; }Efooter { align-self: centre; }