The box model, online

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

The box model in one minute

What students need to know

The content area is the core of the box model, holding the element's actual content. border-box is widely used because the element's total size matches the declared width.

The order outward is: content → padding → border → margin. Margin is the outermost layer — it separates the element from its neighbours.

Mistakes students make

  • div.hover targets a div with class='hover', not all divs. To style all div elements, use div {} without a class selector.
  • A colon is missing after the property name. It should be padding: 15px; not padding 15px;.
  • The CSS property is color (American English), not colour. It should be color: red; not colour: red;.
  • The property name is misspelled. It should be margin: 10px; not margn: 10px;.
PREVIOUS · MODULE 44CSS units
YOU ARE HERE · MODULE 45The box model
NEXT · MODULE 46Padding

Discover other journeys with this module

What students will learn in this module

Every question in Module 45

Quick questions

  1. Which layer sits directly outside the content area?ApaddingBmargin
  2. Which layer sits outside the border?ApaddingBmargin
  3. By default, does width apply to the content area only, or include padding and border?Aincludes padding and borderBcontent area only
  4. Which box-sizing value makes width include padding and border?Aborder-boxBcontent-box
  5. Is padding inside or outside the border?AinsideBoutside

Key terms

Students type the meaning of:

  • box model

Match the pairs

padding: 20px;Match it to what it does
margin: 10px;Match it to what it does
The innermost layer — where text and child elements sitMatch it to what it does
Makes width and height include padding and borderMatch it to what it does
border 2px solid black;Match it to what it does
margn: 10px;Match it to what it does

Fill in the blanks

  1. div {
      _______ 20px;
      border: 1px solid gray;
    }

    Hint: Type the box model property that adds space between the content and the border

  2. div {
      padding: 20px;
      ______: 10px;
    }

    Hint: Type the box model property that adds space outside the border

  3. div {
      _____: 200px;
      padding: 10px;
    }

    Hint: Type the box model property that sets the width of the content area

  4. div {
      border: ___ solid black;
      margin: 5px;
    }

    Hint: Type a pixel value for the border thickness

  5. div {
      box-sizing: __________;
      width: 100px;
    }

    Hint: Type the box-sizing value that includes padding and border inside the width

Spot the error

Question 1

Adiv.hover {B  padding: 10px;C  margin: 5px;

Question 2

Adiv {B  padding 15px;C  margin: 10px;

Question 3

Adiv {B  border: 2px solid black;C  colour: red;

Question 4

Adiv {B  width: 200px;C  padding: 20px;D  margn: 10px;

Question 5

Adiv {B  width: 100px;C  padding: 10px;D  border: 1px solid gray;E  box-sizing: content-box