4 ms·
The W3C box model spec forms a set of consistent rules that make sense. It's not the spec that's wrong. Just because it doesn't fit with your original intuition
by themstheones 15y ago
The W3C box model spec forms a set of consistent rules that make sense. It's not the spec that's wrong. Just because it doesn't fit with your original intuition doesn't make it wrong.
- RyanMcGreal 15y agoA spec that doesn't work the way most people think about the problem and that makes it harder to do what you want in a page layout is wrong more or less by default.
- talmand 15y agoNot wrong in that it is broken in some way, but it is possible for people to look at it and decide it was the wrong decision to make.
- petenixey 15y agoIt's not just an issue with intuition it simply makes it far harder to do many types of layout. One of the biggest failings of the W3C model was that you could not combine a percentage width with fixed margin. If you wanted a fluid layout but which still incorporated consistent margins it was impossible to achieve without an entirely unnecessary nesting of divs. Border-box completely eliminated this and poor old Microsoft (in this one instance) were forced to fall in with the less helpful "standard".
- alexchamberlain 15y agoContent-box eliminated this?
- kbolino 15y agoThe W3C box model would only be useful if the W3C also provided a way to specify a width as "percentage of parent box width minus a fixed number of units" to compensate for the padding adding to the total width. However, they did not, which means that in order to make a decent flowing layout, you have to change your document markup to insert artificial and otherwise unnecessary elements (DIV tags usually). Thus the original model was flawed, did not make sense, and ultimately was not consistent with their own stated goals (separation of content and style). [edit: FWIW petenixey said essentially the same thing, and what's really clever is that he said it first.]
- deleted 15y ago[deleted]
- bzbarsky 15y agoAt this point the W3C is in fact working on providing such a thing. "width: calc(50% - 20px)". Works in Firefox and IE. At some point WebKit will catch up, I assume.
- kbolino 15y agoI'm glad to hear that, but it's long overdue and the border-box model already solves the same problem with less markup (and most importantly, without creating an implicit dependency between the padding and width styles).
- bzbarsky 15y agoWell, in all fairness calc() lets you solve a bunch of problems that border-box can't solve.