The ‘hasLayout’ proprietary property in Internet Explorer for Windows (sort of) [note 1] establishes a new block formatting context [note 2]. This has implications for the behaviour of elements in certain cases. A number of CSS 2.1 properties such as display: table (see also 17.2: the CSS table model) and display:table-cell, the overflow property when set to hidden, scroll or auto and display:inline-block (unsupported by Gecko at time of writing) also establish a new block formatting context, and behave in a similar way as IE for Windows. Below are a number of simple tests intended to illustrate this.
display:tabledisplay:inline-blockdisplay:tabledisplay:inline-blockdisplay:tableIt is important to emphasize it: those are similarities; ‘hasLayout’ only superficially mimics those CSS 2.1 properties. For some more details and a background on those tests, see Georg Sørtun's analysis.
display:table does not generate a new block formattting context by itself. However, an element with display:table generates a number of anonymous boxes, one of them being a box with display:table-cell. It is that last anonymous box that establishes the new block formatting context.display:inline-block is basically an inline element: (it) generate(s) a block box, which itself is flowed as a single inline box(definition). In other words, the object is rendered inline, but its content is rendered as if it where inside a block element. The same applies to
display:inline-table, see the description of this display value. As such, within a block box, they behave more like replaced elements such as images. A special case of inline-block elements are form controls.The border box of a table, a block-level replaced element, or an element in the normal flow that establishes a new block formatting context (such as an element with ‘overflow’ other than ‘visible’) must not overlap any floats in the same block formatting context as the element itself. If necessary, implementations should clear the said element by placing it below any preceding floats, but may place it adjacent to such floats if there is sufficient space.
Elements that do have layout may establish a new block formatting context (9.4.1 in the CSS 2.1 spec)
Last modified: August 24 2007 11:30:33 GMT.