CSS Box Model : Diagram
THE BOX MODEL
The box model comprises the set of properties that define parts of an element that take up space on a web page. The model includes the content area’s size (width and height) and the element’s padding, border, and margin. The properties include:
width
andheight
: 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 edge of the element.
Question
what are the default values of padding, border, and margin?
Answer
Depending on each browser those values will vary, therefore is commonly recommended to “reset” those values to 0 in a CSS file. Browsers provide default values for a general support for legible content, but sometimes they will get on your way. Another thing is that not all tags get the same default values for padding or margin, although the only default value for border is medium none currentcolor
where medium
is the thickness, none
is the style, and currentcolor
sets it to the color of the background.
Here is a list of common tags and their most common default values:
body - margin: 8px; h1 - margin-top: 0.67em; margin-bottom: 0.67em; h2 - margin-top: 0.83em; margin-bottom: 0.83em; h3 - margin-top: 1em; margin-bottom: 1em; h4 - margin-top: 1.33em; margin-bottom: 1.33em; h5 - margin-top: 1.67em; margin-bottom: 1.67em; h6 - margin-top: 2.33em; margin-bottom: 2.33em; p - margin-top: 1em; margin-bottom: 1em; ol - margin-top: 1em; margin-bottom: 1em; padding-left: 40px; ul - margin-top: 1em; margin-bottom: 1em; padding-left: 40px;
Comments
Post a Comment