box-sizing, online

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

box-sizing in one minute

What students need to know

The * universal selector targets all elements, making border-box the base sizing model. Browsers default to content-box, so padding and border expand the element beyond its declared width.

CSS values use hyphens, not underscores. border_box is not a recognised value. The property is box-sizing (with an 'i'). box-sizng is not a valid CSS property.

Mistakes students make

  • box-sizing is a CSS property, not a class name. The selector .box-sizing targets elements with class='box-sizing'. To apply box-sizing to all elements use * {} or target the correct selector.
  • The property name is misspelled. It should be box-sizing: border-box; not box-sizng: border-box;.
  • CSS values use hyphens, not underscores. It should be box-sizing: content-box; not box-sizing: content_box;.
  • The declaration is missing a semicolon at the end. It should be padding: 20px; not padding: 20px.

Discover other journeys with this module

What students will learn in this module

Every question in Module 50

Quick questions

  1. With border-box, if width is 200px and padding is 20px, what is the total rendered width?A240pxB200px
  2. With content-box, if width is 200px and padding is 20px, what is the total rendered width?A240pxB200px
  3. Which is the default value of box-sizing?Acontent-boxBborder-box
  4. Which selector applies box-sizing to every element on the page?A* { box-sizing: border-box; }Bbody { box-sizing: border-box; }
  5. Does border-box include margin in the declared width?AYes — margin is includedBNo — margin is always outside

Key terms

Students type the meaning of:

  • box-sizing

Match the pairs

box-sizing: border-box;Match it to what it does
box-sizing: content-box;Match it to what it does
Apply border-box to every element as a global resetMatch it to what it does
The default box-sizing value used by browsersMatch it to what it does
box-sizng: border-box;Match it to what it does
box-sizing: border_box;Match it to what it does

Fill in the blanks

  1. * {
      box-sizing: __________;
    }

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

  2. div {
      __________: content-box;
    }

    Hint: Type the CSS property that controls how width and height are calculated

  3. p {
      box-sizing: ___________;
    }

    Hint: Type the box-sizing value that measures the content area only, excluding padding and border

  4. div {
      box-sizing: __________;
      width: 200px;
    }

    Hint: Type the value that makes the 200px width include any padding and border

  5. div {
      box-sizing: border-box;
      _____: 300px;
    }

    Hint: Type the property that sets the total horizontal size of the element

Spot the error

Question 1

A.box-sizing {B  width: 100px;C  padding: 10px;

Question 2

Adiv {B  box-sizng: border-box;C  width: 200px;

Question 3

A* {B  padding: 0;C  box-sizing: content_box;

Question 4

Adiv {B  box-sizing: border-box;C  width: 250px;D  padding: 20px

Question 5

Asection {B  box-sizing: border-box;C  width: 100%;D  padding: 16px;E  border: 1px solid gray