Re: Width of an absolute positioned element

On 7/22/03 1:57 PM, "Boris Zbarsky" <bzbarsky@MIT.EDU> wrote:

> 
> Chris Moschini wrote:
>> Consider that in any of those browsers, absolutely positioning
>> Element B inside Element A and setting B's width to 100% causes it to
>> be 100% of the width of A.
> 
> No, it causes Element B to be 100% of the width of its containing block.
> This is only Element A if Element A is positioned or is the root
> element (in CSS2; CSS2.1, as it stands, has that part a little rewritten).\

Almost correct.  Many "HTML UAs" have historically treated the <BODY>
element as the root element, since, as far as HTML is concerned, the <BODY>
*is* the root element for display purposes.

And for absolutely positioned elements, if there is no positioned ancestor,
then the "initial containing block" is the containing block.  The initial
containing block is left as UA-defined, although typically resembles the
"viewport" or the "root element" as you have observed.

Per the looseness of the definition of initial containing block, all the
interpretations you report can be interpreted as compliant.  The easiest way
to eliminate this ambiguity as an author is to pick what element you want as
the "initial containing block" and set "position:relative" on it.

And yes, this portion of CSS2.1 is still in flux.

Tantek

Received on Tuesday, 22 July 2003 18:52:56 UTC