The illustration below shows these various parts. Borders come in various styles. Background settings for an element apply to the the area just inside the borders which includes both the padding and content areas. For purposes of illustration however, the padding area is shown in a slightly darker color. Margins, borders and padding are all optional but for purposes of calculating positions and sizes they are given a default width of zero if not specified.
Margins can even have negative values.
The width and height of each box is equal to the width and height of the outer margin box. Note that this is not the necessarily the same as the width and height of the content area. A box can contain any number of other boxes, creating a hierarchy of boxes that corresponds to the nesting of page elements. The browser window serves as the root element for this hierarchy. Box Types There are two basic types of boxes, block and inline.