Internet Explorer box model bug
From Wikipedia, the free encyclopedia
The Internet Explorer box model bug is one of the best-known software bugs[citation needed] in a popular implementation of Cascading Style Sheets (CSS). It affects CSS-aware versions of Microsoft’s Internet Explorer Web browser for Windows up to version six. Internet Explorer 6 and newer are not affected in their standards-compliant mode; they are affected only in “quirks modeâ€. The bug did not affect Internet Explorer for Mac on the Apple Macintosh platform, although development for it ended in 2003.
Contents
[edit] Bug
The CSS box model describes how certain elements of Web pages are displayed by graphical browsers. The box model allows block-level elements—such as p and blockquote—to be surrounded by padding, borders, and margins. According to the CSS1 specification, released by the World Wide Web Consortium (W3C) in 1996 and revised in 1999, when a width or height is explicitly specified for any block-level element, it should determine only the width or height of the content within the box, with the padding, borders, and margins applied afterward. [1][2]Internet Explorer 5 incorrectly includes the padding and borders within a specified width or height; this results in a narrower or shorter rendering of a box.[3]
[edit] Workarounds
Internet Explorer versions 6 and 7 are not affected by the bug if the page contains certain HTML document type declarations. These versions maintain the buggy behavior when in quirks mode for reasons of backward compatibility.[4] For example, quirks mode is triggered:
Various workarounds have been devised to force Internet Explorer versions 5 and earlier to display Web pages correctly. These workarounds generally exploit unrelated bugs in Internet Explorer’s CSS selector processing in order to hide certain rules from the browser. The best known of these workarounds is the “box model hack†developed by Tantek Çelik. Çelik developed this idea during his time at Microsoft while working on Internet Explorer for the Macintosh, which is not affected by the bug. It involves specifying a width declaration for Internet Explorer for Windows, and then overriding it with another width declaration for CSS-compliant browsers. This second declaration is hidden from Internet Explorer for Windows by exploiting other bugs in the way that that browser parses CSS rules. The implementation of these CSS “hacks†has been further complicated by the public release of Internet Explorer 7, which has had some issues fixed, but not others.[4]
Box model hacks have proven unreliable because they rely on bugs in browsers’ CSS support that may be fixed in later versions. For this reason, some Web developers have instead recommended either avoiding specifying both width and padding for the same element or using conditional comment and/or CSS filter to work around the box model bug in older versions of Internet Explorer.[6][7]
[edit] Support for Internet Explorer's box model
Web design professionals Douglas Bowman and Ethan Marcotte have stated that the original Internet Explorer box model actually represents a better, more logical approach based on common sense.[8][9] An example given by Peter-Paul Koch is a physical, real-world box, whose dimensions always refer to the box itself, including potential padding, but never its content.[10] In CSS designs, this definition allows the exact application of both relative dimensions and absolute padding to any given box, which is not possible with the W3C model without workarounds.[11] Peter-Paul Koch also says that this box model is more useful for graphic designers, who create designs based on the visible width of boxes rather than the supposed width of their content.[12] Another argument, given by Bernie Zimmermann in support of the Internet Explorer box model, is its closeness to the definition of cell dimensions and padding in the HTML table model, as defined by the W3C and implemented in most browsers.[13]
In some early CSS3 Box Model Specification and Basic User Interface Module drafts, the W3C considered an explicit choice of box models via proposed box-width and box-height properties. These are not included in the current CSS3 draft.


