CSS Box Model

CSS Box Model, the layout of web pages document, the browser’s engine represents the web Pages element as a rectangular box according to the standard CSS

basic box model. Every CSS box model is represented of four areas (or parts), defined by their respective edges: padding edge border edge margin edge content edge

because the CSS determines the properties, position, size and such as properties (i.e. background, color, border size, etc.) of these boxes.

css box model

CSS Box Model Properties

1. Margin Edge:-

The margin edge defines as its bounded by the margin edge, as represented in the Image, extends the border area

to include an empty area used to separate the element from its neighbors.

therefore, Its dimensions (Area) are the margin-box width and the margin-box height.

therefore the size of the margin area can be determined and margin-top margin-bottom margin-left margin-right shorthand margin properties.

In the case, When margin collapsing occurs, in web pages, the margin area is not clearly defined since margins area shared between boxes.

2. Border Edge:-

The border Edge area defined as, it’s bounded by the border edge as seen in the above Image, extends the padding

an area to include the element’s borders.

Border edge (area) dimensions are the border-box width and the border-box height. finally, we can determine the area

with border-box width and border-box height.

as a result, If you want to determine the thickness of the borders, can be determined by the border-width and shorthand border properties.

the border area’s size can be defined in the CSS with the properties. width min-width max-width height min-height max-height

When there is a background (background-image or background-color) set on a box, it extends to the outer edge of the border.

therefore, the border-edge as a default behavior can be altered with the background-clip CSS property.

3. Padding Edge:-

The padding area defined as it is bounded by the padding edge, it can extend by the content area to include the element’s padding.

finally, Padding area can be dimensioned by the padding-box width and the padding-box height.

If you want to calculate the thickness of the padding it’s can be determined shorthand padding properties.padding-top padding-bottom padding-left padding-right

4. Content Edge:-

The content area defined as, it’s bounded by the content edge, contains are such as text which will be real content, a video player or an image.

Its dimensions determined with the content-box width (content width) and the content-box height (content height),

It often has a background image or background color.

therefore, the content area’s size can be defined with the properties. width min-width max-width height min-height max-height

Let us see the Example

css box model

Therefore In the above example, you can see the Margin edge, where written in CSS Box Model Properties, border edge where border color #29d8b8 Padding edge where Background-color is in#5f9ea0; the Image, content Edge when written the Content in the above Image.