Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How box Model works?

Sometime, we face issue of alignment of elements even if we gave proper Width and height to them. One of the reason behind is we had not followed the CSS box model.
Let me explain box model to explain this in detail.

Let say, we have given 500px width and 500px height to the div. Surrounding border is given 5px, padding 10px and margin 10px;
In this case we cannot say that the element width is 500px. Because, we have not included the border width, padding and margin.

Total width of DIV: content width+left padding+right padding+left border+right border+left margin+right margin
It means, Total width of DIV = 500+10 (left padding)+10 (right padding)+5 (border left)+5 (border right)+10 (margin left)+10 (margin right) = 550px




This post first appeared on Frontend Skills, please read the originial post: here

Share the post

How box Model works?

×

Subscribe to Frontend Skills

Get updates delivered right to your inbox!

Thank you for your subscription

×