Skip to content

Courses / CSS3 Mastery: Beginner to Advanced / CSS Box Model

2,090 people viewed this

CSS Box Model

Practice Exercise

Create three boxes with different widths, padding, borders and margins. Calculate their border-box widths manually, then use browser DevTools to verify the calculations.

Quiz — 10 MCQs

  1. Which four areas make up the traditional box model? (A) Content, padding, border, margin (B) Header, footer, body, title (C) Grid, flex, float, clear (D) Width, height, color, font. Answer: A. These are the four box-model areas.
  2. Which area sits directly around the content? (A) Margin (B) Padding (C) Outline (D) Position. Answer: B. Padding lies between content and border.
  3. Which area is outside the border? (A) Content (B) Padding (C) Margin (D) Line height. Answer: C. Margin separates the box from neighboring content.
  4. What is the default box-sizing value for ordinary elements? (A) border-box (B) content-box (C) margin-box (D) padding-box. Answer: B. The default is content-box.
  5. With content-box, what is the border-box width for width 200px, horizontal padding 20px per side and 5px borders per side? (A) 200px (B) 230px (C) 250px (D) 290px. Answer: C. 200 + 40 + 10 = 250px.
  6. What does border-box include in its declared width? (A) Content, padding and border (B) Margin only (C) Margin and outline only (D) Content only. Answer: A. Margins remain outside the border box.
  7. Which shorthand sets top and bottom to 10px and left and right to 20px? (A) padding: 10px 20px (B) padding: 20px 10px (C) padding: 10px (D) padding: 10px 20px 30px. Answer: A. Two-value shorthand means vertical then horizontal.
  8. Can vertical margins collapse in some block layouts? (A) Yes (B) Never (C) Only on images (D) Only with Grid. Answer: A. Adjacent block margins can collapse under specific conditions.
  9. Do margins count inside a border-box width? (A) Yes (B) No (C) Only when colored (D) Always on mobile. Answer: B. Margins lie outside the border box.
  10. Which tool helps inspect an element's box model? (A) Browser DevTools (B) A database editor (C) Git log only (D) Email client. Answer: A. DevTools displays dimensions, padding, borders and margins.

Key Takeaways

  • Understand the four box-model areas.
  • Use border-box for predictable component sizing.
  • Know the shorthand order and when vertical margins collapse.

Rate this course

No ratings yet — yours can be the first.

Stars show on this course. Your written note stays private.

Your stars