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.

Discover other journeys with this module

What students will learn in this module

Every question in Module 46

Quick questions

  1. What does padding: 10px 20px; set?A10px left and 20px topB10px top/bottom and 20px left/right
  2. What is the order of sides in a 4-value padding shorthand?ATop, right, bottom, left (clockwise)BTop, bottom, left, right
  3. True or false: padding adds space outside the element's border.AFalseBTrue
  4. Which property sets only the left-side padding?Apadding-leftBpadding-right
  5. 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 does
div {
  padding: 5px 10px 15px 20px;
}
Match it to what it does
Padding adds space inside the border — between the content and the element's edgeMatch it to what it does
Individual side properties let you set padding on one side onlyMatch it to what it does
p { padding: -10px; }Match it to what it does
div { padding: 10px, 20px; }Match it to what it does

Fill in the blanks

  1. p { _______: 10px; }

    Hint: Type the CSS property name that sets space inside an element's border

  2. div { ___________: 20px; }

    Hint: Type the CSS longhand property name that sets only the top inside spacing

  3. a { ____________: 12px; }

    Hint: Type the CSS longhand property name that sets only the left inside spacing

  4. p { padding: 10px ____; }

    Hint: Type the CSS value that sets the left and right padding to 20 pixels

  5. 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; }