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.
What students will learn in this module
Every question in Module 50
Quick questions
- With border-box, if width is 200px and padding is 20px, what is the total rendered width?A240pxB200px
- With content-box, if width is 200px and padding is 20px, what is the total rendered width?A240pxB200px
- Which is the default value of box-sizing?Acontent-boxBborder-box
- Which selector applies box-sizing to every element on the page?A* { box-sizing: border-box; }Bbody { box-sizing: border-box; }
- 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 doesbox-sizing: content-box;Match it to what it doesApply border-box to every element as a global resetMatch it to what it doesThe default box-sizing value used by browsersMatch it to what it doesbox-sizng: border-box;Match it to what it doesbox-sizing: border_box;Match it to what it doesFill in the blanks
* { box-sizing: __________; }Hint: Type the box-sizing value that includes padding and border inside the width
div { __________: content-box; }Hint: Type the CSS property that controls how width and height are calculated
p { box-sizing: ___________; }Hint: Type the box-sizing value that measures the content area only, excluding padding and border
div { box-sizing: __________; width: 200px; }Hint: Type the value that makes the 200px width include any padding and border
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
