The CSS Box Model is the foundation of layout design in CSS. Every HTML element is a box made up of 4 areas:
This is content inside the box.
box-sizing: border-box
is used).
.box { width: 300px; padding: 20px; border: 2px solid #007BFF; margin: 20px; background-color: #f8f9fa; }
box-sizing
controls whether padding and border are included in the total width/height of the box.
.box { box-sizing: border-box; }
This makes the total width and height stay as defined, even after adding padding or borders.
Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!