Skip to content
Learn Netverks

Lesson

Step 7/31 23% through track

box-model-lab

Box model in real components

Last reviewed May 28, 2026 Content v20260528
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~1 min
Level
beginner

This lesson

This lesson teaches Box model in real components—the ideas, syntax, and habits you need before moving on in HTML & CSS.

Without a solid grasp of Box model in real components, you will repeat mistakes in HTML & CSS exercises and on real pages or scripts.

You will apply Box model in real components in contexts like: Landing pages, dashboards, marketing sites, and portfolio pieces built without a framework.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also complete the hands-on challenge before advancing.

When the previous lesson's MCQs feel easy and you can explain Box model in real components in your own words.

Every element is a rectangular box: content, padding, border, and margin. Layout bugs often come from margin collapse or forgetting box-sizing.

box-sizing: border-box

With border-box, width includes padding and border—setting width: 200px usually means “200px on screen,” which matches intuition for cards and grids.

Margin vs padding

  • Padding — space inside the border (background extends here).
  • Margin — space outside the border (separates siblings).

Practice

  1. Increase .card padding—content breathes, border grows outward with border-box.
  2. Change margin on .card—see gap between cards.
  3. Set box-sizing: content-box on one card and compare widths.

Important interview questions and answers

  1. Q: What does `box-sizing: border-box` change?
    A: Width/height include padding and border, not only content.
  2. Q: Padding vs margin?
    A: Padding is inside the border; margin is outside between elements.
  3. Q: Why do adjacent vertical margins sometimes collapse?
    A: CSS collapses certain vertical margins between block siblings—use padding or flex/grid gaps when you need guaranteed spacing.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What part of this lesson needs a second read?
  • What would you try differently in a real project?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump