KandZ – Tuts

We like to help…!

CSS 14 💻 box model

Box Model is a fundamental concept in CSS
It defines how elements structured and displayed
Content Area → This is the actual space occupied by the element's content
Padding → this is the space between the content area and the border
it creates some space around the content to create visual separation.
Border → this is the line that separates the padding from the content area.
Margin → This is the space between an element and its adjacent elements.

standard CSS box model → The box size of an elements is defined by its width and height...
plus border and padding
.box width → 150 + 5 + 5 + 25 + 25 = 210px
.box height → 50 + 5 + 5 + 25 + 25 = 110px
alternative CSS box model → The box size of an elements is defined by its width and height
The content area width and height is calculated by subtract padding and border
to use the alternative model for an element, use box-sizing: border-box
for all the elements use...
*, *::before, *::after{
box-sizing: border-box;
}

Leave a Reply