The Box Model Flashcards
What are the 5 things of the box model
Margin, Border, Padding, Width and Height (Content)
Width and Height
The width and height of the content area
Padding
The amount of space between the content area and the border
Border
The thickness and style of the border surrounding the content area and padding
Margin
The amount of space between the border and the outside of the element
How to change the height and width of an element
Using the height and width properties
Example:
p {
height: 80px;
width: 240px;
}
Border Width
The thickness of the border, can be set in pixels or with the keywords thin, medium, or thick
Border style
The design of the border, there are 10 different ones with the most common being none, dotted, and solid
Border color
The color of the border
How to change how a border looks
With the border property
Example:
p {
border: 3px solid coral;
}
How to change the border radius?
With the border-radius property
Example:
p {
border-radius: 5px;
}
How to make a border a perfect circle?
By setting the height and width to be the same, then making the border radius’ value 50%
How do you change how large the padding is?
Using the padding property
Example:
h1 {
padding: 10px;
}
How do you change the amount of padding on each side?
For 4, 3, and 2 value
By adding multiple numbers
Example:
h1 {
padding: 5px 10px 15px 5px <em>This would mean (top, right, bottom, left)</em>
}
For 3 values, the middle value would set the left and right padding
For 2 values, the first one sets the top and bottom, and the second one does right and left.
*** also works for margin
How to change the margin of an element
Using the margin property
Ex:
p {
margin: 20px;
}