Learn CSS - The Box Model Cheatsheet - Codecademy
Learn CSS - The Box Model Cheatsheet - Codecademy
The CSS box model is a box that wraps around an HTML .container {
element and controls the design and layout. The
box-sizing: border-box;
property box-sizing controls which aspect of the box
is determined by the height and width properties. }
The default value of this property is content-box ,
which renders the actual size of the element including
the content box; but not the paddings and borders. The
value border-box , on the other hand, renders the
actual size of an element including the content box,
paddings, and borders.
https://www.codecademy.com/learn/learn-css/modules/learn-css-box-model/cheatsheet 1/3
12/26/23, 11:00 AM Learn CSS: The Box Model Cheatsheet | Codecademy
CSS margin collapse occurs when the top and bottom /* The vertical margins will collapse to
margins of blocks are combined into a single margin
30 pixels
equal to the largest individual block margin.
Margin collapse only occurs with vertical margins, not instead of adding to 50 pixels. */
for horizontal margins. .block-one {
margin: 20px;
}
.block-two {
margin: 30px;
}
https://www.codecademy.com/learn/learn-css/modules/learn-css-box-model/cheatsheet 2/3
12/26/23, 11:00 AM Learn CSS: The Box Model Cheatsheet | Codecademy
The CSS min-width and min-height properties can /* Any element with class "column" will
be used to set a minimum width and minimum height of
be at most 200 pixels wide, despite the
an element’s box. CSS max-width and max-height
properties can be used to set maximum widths and width property value of 500 pixels. */
heights for element boxes.
.column {
max-width: 200px;
width: 500px;
}
Print Share
https://www.codecademy.com/learn/learn-css/modules/learn-css-box-model/cheatsheet 3/3