Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the advantage of W3C box model compared with IE5 box model?

I think the IE5 box model is more similar to human's logic about box's concept,withing including padding and border.It can defined the box width and height directly.

In cases in which you have an element with a width of 100%, the IE5 box model allows you to add padding and borders safely. Compare this to the correct CSS box model, in which you cannot add any padding or borders to an element with a width of 100% without breaking the layout

So any one could explain it in details?What is the W3C box model advantages?

Thank you

like image 820
hh54188 Avatar asked Jan 02 '11 03:01

hh54188


People also ask

What do you think is the advantage of having a CSS box model?

Quite simply, the CSS Box Model provides a guide to layout those elements. The CSS Box Model is used to create a definition for the way the HTML elements are organized on the screen. This approach accounts for options such as margins, padding, borders, and all the properties that manipulate them.

What is the difference between a content box model and a border box model?

In the content box model, the content inside of element will have the same dimension as the element. In the border box model, the content's dimension has to subtract the border and padding from the element's dimension.

What is the difference between box-sizing content box and box-sizing border box?

border-box and content-box are the two different values of box-sizing. content-box: This is the default value of box-sizing. The dimension of element only includes 'height' and 'width' and does not include 'border' and 'padding' given to element. Padding and Border take space outside the element.

What does * box-sizing border box do what are its advantages?

The box-sizing property allows us to include the padding and border in an element's total width and height. If you set box-sizing: border-box; on an element, padding and border are included in the width and height: Both divs are the same size now! Hooray!


1 Answers

The 100% example is sometimes a valid issue with the W3C box model, however it is mostly a moot point because you can use the following code and achieve what you are referring to as the "IE 5 box model":

box-sizing: border-box;

/* probably not needed in 2016 */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;

box-sizing is available in all major browsers IE8+. I use it exclusively now; Microsoft had this one right, in my opinion.

Also See

  • Why is the W3C box model considered better?
like image 69
Tim M. Avatar answered Nov 15 '22 11:11

Tim M.