Padding, online
Six activities your students do on their own devices. See who's finished, and their scores.
Padding in one minute
What students need to know
padding: 20px adds 20px of space on all four sides inside the border, pushing the content away from the edges. padding-top and padding-left set only their respective sides, leaving the other sides unchanged.
With two values, the first sets top and bottom, the second sets left and right. This is the standard 2-value shorthand pattern. The padding shorthand accepts 1, 2, 3 or 4 values. Five values is invalid and will be ignored by the browser.
Mistakes students make
- CSS declarations require a colon. It should be padding: 10px; not padding 10px;.
- The padding shorthand accepts 1, 2, 3 or 4 values — not 5. Five values is invalid CSS.
- CSS declarations require a colon. It should be padding-top: 15px; not padding-top 15px;.
- 'padding: top 10px' is invalid. To set only the top padding use padding-top: 10px; or include all sides in the shorthand.
What students will learn in this module
Every question in Module 46
Quick questions
- What does padding: 10px 20px; set?A10px left and 20px topB10px top/bottom and 20px left/right
- What is the order of sides in a 4-value padding shorthand?ATop, right, bottom, left (clockwise)BTop, bottom, left, right
- True or false: padding adds space outside the element's border.AFalseBTrue
- Which property sets only the left-side padding?Apadding-leftBpadding-right
- True or false: padding: 10px 20px 30px 40px 50px is valid CSS.ATrueBFalse
Key terms
Students type the meaning of:
padding
Match the pairs
p { padding: 10px 20px; }Match it to what it doesdiv {
padding: 5px 10px 15px 20px;
}Match it to what it doesPadding adds space inside the border — between the content and the element's edgeMatch it to what it doesIndividual side properties let you set padding on one side onlyMatch it to what it doesp { padding: -10px; }Match it to what it doesdiv { padding: 10px, 20px; }Match it to what it doesFill in the blanks
p { _______: 10px; }Hint: Type the CSS property name that sets space inside an element's border
div { ___________: 20px; }Hint: Type the CSS longhand property name that sets only the top inside spacing
a { ____________: 12px; }Hint: Type the CSS longhand property name that sets only the left inside spacing
p { padding: 10px ____; }Hint: Type the CSS value that sets the left and right padding to 20 pixels
div { ______________: 0; }Hint: Type the CSS longhand property name that sets only the bottom inside spacing
Spot the error
Question 1
Ap { padding 10px; }Bh1 { padding: 20px; }Cdiv { padding: 5px 10px; }
Question 2
Ap { padding: 10px; }Bdiv { padding: 10px 20px 30px 40px 50px; }Ca { padding: 5px; }
Question 3
Ap { padding: 10px; }Bh1 { padding: 0 20px; }Cdiv { padding-top 15px; }
Question 4
Ap { padding: 10px; }Bdiv { padding: 5px 10px; }Ch2 { padding: 0; }Da { padding: top 10px; }
Question 5
Ap { padding: 10px; }Bh1 { padding: 20px 0; }Cdiv { padding: 5px 10px 15px; }Dspan { padding: 8px; }Ea { padding-left 12px; }
