CSS Box Model - Definition & Components
SponsoredPrepare for Your CSS Box Model with Our Selection of Courses! Find the Right Course to Suit Your Needs and Budget. We Have Them All!Water exerts force · Learn social psychology · 970 Quiz Questions
Types: Practice tests & problems, Study guides, Textbook solutions, Online learning4.5/5 (2,892 reviews)
- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
The CSS Box Model is the foundation of web layout design. It treats every HTML element as a rectangular box made up of content, padding, border, and margin. Understanding it is essential for accurate sizing and spacing of elements.
Structure of the Box Model:
Content: The actual text, image, or other media inside the element.
Padding: Transparent space between the content and the border.
Border: A visible line surrounding the padding and content.
Margin: Transparent space outside the border, separating the element from others.
Example: Basic Box Model in CSS
div {width: 300px; /* Content width */border: 15px solid green; /* Border thickness */padding: 50px; /* Space inside border */margin: 20px; /* Space outside border */}Copied!✕CopyCalculation of Total Size:
Total Width = content width (300px) + left/right padding (100px) + left/right border (30px) = 430px
Total Height is calculated similarly by adding padding and border to the content height.
Example: box-sizing Impact
CSS Box Model - W3Schools
The CSS Box Model In CSS, the term "box model" is used when talking about web design and layout. The CSS box model is essentially a box that wraps around every HTML element. Every box consists of four …
Code sample
div {width: 300px;padding: 25px;border: 25px solid navy;margin: 25px;...CSS Box Model (With Examples) - Programiz
The CSS box model is a fundamental concept that defines how the element’s dimensions and spacing are calculated. In this tutorial, you will learn about the CSS box model with the help of examples.
CSS Box Model (with Example) - Scientech Easy
Sep 26, 2025 · The CSS box model is a fundamental concept in which an HTML document is viewed as a hierarchy of rectangular boxes. Each box in the …
CSS Box Model Properties – Explained With Examples
Jul 22, 2021 · Today we're gonna learn how to use the CSS box model with examples. This will help you make pixel perfect websites and will teach you to …
Searches you might like
CSS Box Model - GeeksforGeeks
Nov 6, 2025 · Each element in the box model is made up of distinct layers that define its size and spacing on a web page. 1. Content Area. The content area is …
CSS Box Model: Complete Explanation with Examples
Dec 21, 2025 · Each element in CSS is treated as a CSS Box Model because each element has its own box. Typically, every element in CSS is recognized as a box, even if it appears as a circle or another …
CSS box model - MDN Web Docs
Dec 16, 2025 · Every visible element on a webpage is a box laid out according to the visual formatting model. CSS properties define their size, position, and stacking level, with the box model properties …
Box Model | The Ultimate CSS Showcase
The CSS box model describes how every element is rendered as a rectangular box, consisting of content, padding, border, and margin layers. 3 "token comment">/* Content dimensions */ 4 "token …
CSS Box Model: Components, Properties & Real-World Examples
Oct 9, 2025 · Every HTML element on a web page is essentially a box. The CSS Box Model defines how these boxes are structured, how much space they take up, and how they relate to each other.