CodeToLive

CSS Box Model

The CSS Box Model describes the design and layout of elements, consisting of margin, border, padding, and content.

Box Model Example


.box {
  width: 200px;
  height: 100px;
  padding: 20px;
  border: 5px solid black;
  margin: 10px;
}
      

Box-Sizing Property


.box {
  box-sizing: border-box; /* Includes padding and border in the element's total width/height */
}
      
Next: CSS Layouts