nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

HTML/Box model

Content, padding, border and margin: how the browser calculates the space every element takes up.

10 QuestionsIntermediateHigh Priority ~10 min read

Every element is rendered as a rectangular box made of four layers: the content area, padding around it, a border around the padding, and margin outside the border. By default (box-sizing: content-box) the width and height you set apply only to the content, so padding and border are added on top, and a 200px-wide box with 20px padding and a 5px border actually occupies 250px horizontally.

That surprise is why many projects reset to box-sizing: border-box, where width and height include padding and border, making sizes far more predictable. Interviewers also ask about margin collapsing, where adjacent vertical margins of block elements merge into the larger one rather than adding up, and about the difference between padding (inside, takes the element's background) and margin (outside, always transparent). Knowing how to inspect the box model in browser dev tools is a practical bonus.

What you'll walk away knowing

The four layers of the box model and how each contributes to an element's size
The difference between content-box and border-box and why border-box is popular
How margin collapsing works and when it happens
Padding versus margin: where each sits and how it behaves with backgrounds

No questions match "".

All Topics
1
Basics
Common Tags
Attributes and Elements
Lists
Text tags and Formatting
2
Input and Forms
Block and Inline Elements
Box model
3
Semantic Tags
Links and Images
Media and Embeds
Tables
HTML entities
HTML and CSS
4
Performance
SEO
Progressive Enhancement
5
HTML5
Custom Elements & Web Components
HTML5 APIs
SPAs
6
WCAG
Security
Best Practices
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.