In a document, each element is represented as a rectangular box. Determining the size, properties — like its color, background, borders aspect — and the position of these boxes is the goal of the rendering engine.
In CSS, each of these rectangular boxes is described using the standard box model. This model describes the content of the space taken by an element. Each box has four edges: the margin edge, border edge, padding edge, and content edge.
The content area is the area containing the real content of the element. It is located inside the content edge, and its dimensions are the content width, or content-box width, and the content height, or content-box height.
The padding area extends the content area with the empty area between the content and the eventual borders surrounding it. It often has a background, a color or an image (in that order, an opaque image hiding the background color), and is located inside the padding edge. Its dimensions are the padding-box width and the padding-box height.
The border area extends the padding area with the area containing the borders. It is the area inside the border edge, and its dimensions are the border-box width and the border-box height. This area depends of the size of the border that is defined by the
border-width property or the shorthand
The margin area extends the border area with an empty area used to separate the element from its neighbors. It is the area inside the margin edge, and its dimensions are the margin-box width and the margin-box height.
Finally, note that, for non-replaced inline elements, the amount of space taken up (the contribution to the height of the line) is determined by the
line-height property, even though the border and padding appear visually around the content.
|CSS Level 2 (revision 1)||Recommendation||Though more precisely worded, there is no practical change|
|CSS Level 1||Recommendation|
- CSS Reference
- CSS Key Concepts: CSS syntax, specificity and inheritance, the box, layout modes and visual formatting models, and margin collapsing, or the initial, computed, used and actual values. Definitions of value syntax, shorthand properties and replaced elements.
- Related CSS properties: