W3C home > Mailing lists > Public > www-style@w3.org > May 2002

Re: Percentage heights and the ICB

From: Tantek Çelik <tantek@cs.stanford.edu>
Date: Sat, 04 May 2002 11:14:40 -0700
To: Andrew Clover <and@doxdesk.com>, www-style@w3.org
Message-id: <B8F97320.BDB8%tantek@cs.stanford.edu>
On 5/4/02 6:12 AM, "Andrew Clover" <and@doxdesk.com> wrote:

> RSL <swim@catholic.org> wrote on webdesign-l:
> 
>> ie5 mac [...] does *not* like a percentages with the top
>> property.

Please send ie5 mac bug reports to the archived[1] mailing list
macietalk[2].


> Yes, this is exactly the same thing. To use a percentage in any
> of top/bottom/height, the browser must know how high the
> containing block is.

True.


> Oddly CSS does not enforce this. It says about the height
> property (and similarly for min-height, max-height):
> 
>> The percentage is calculated with respect to the height of the
>> generated box's containing block. If the height of the containing
>> block is not specified explicitly (i.e., it depends on content
>> height), the value is interpreted like 'auto'.
> 
> but there is no similar wording about 'top' and 'bottom'. So
> whilst you could theoretically use 'top: 25%; bottom: 25%;',
> you'd not be able to use 'top: 25%; height: 50%;'.

Note that the definition of "containing block" is different for absolutely
positioned elements (position:absolute | fixed) than it is for
non-positioned elements.[3]


> IMHO this limitation (can't use % height if CB height is 'auto')
> makes no sense for absolutely positioned elements and should
> be limited to non-absolutely-positioned elements. An absolutely-
> positioned element cannot affect the size of its ancestor, so the
> limitation serves no purpose.

This seems reasonable to me.


> Sam Marshall <S.Marshall@open.ac.uk> wrote:
> 
>> In other words, the initial containing block (the block generated by
>> the HTML tag) should be as big as necessary to fit the document - *not*
>> as big as the viewport.
> 
>> (On the other hand, its width is defined by the user agent which may use
>> the viewport width. Yay consistency.)
> 
> Yay indeed.
> 
> Also 10.1 says:
> 
>> The containing block (called the initial containing block) in which
>> the root element lives is chosen by the user agent.
> 
> this mildly contradicts 9.1.2, which say the root element *generates*
> the ICB, not lives inside it. The wording "chosen by the UA" also suggests
> it being the same size as the viewport (this style of working is also
> used in 9.2.1). This seems to be the approach taken by IE/Win and
> Mozilla.
> 
> So, what happens when the height of the root element is a percentage?
> I see nothing to specify what it's relative to, but it would be
> extremely helpful if it were specified to be the viewport.

There was a previous thread on www-style which concluded that
implementations may interpret percentage height on the root element as
relative to the height of the viewport[4], and indeed, this is what IE/Win
does.


> As far as
> I can tell (not having a Mac), IE/Mac seems to treat it as relative
> to the current screen resolution instead. Which isn't handy at all.

I don't think that is the behavior.  Again, please send specifics to
MacIE-Talk[2].


>> If you want something relative to the viewport's height, according
>> to the spec, you should use position:fixed. (As far as I can see.)

Yes, but the root element should work also (IMHO).


> I concur. But am Ccing to www-style, where there are language lawyers
> more wily than I, to see if there is a better answer.

Tantek (not a lawyer)

[1]
http://www.mail-archive.com/macie-talk%40lists.boingo.com/

[2]
To subscribe to MacIE-Talk send mail to:  MacIE-Talk-On@lists.letterrip.com
To subscribe to the digest:  MacIE-Talk-digest@lists.letterrip.com
To post to MacIE-Talk send mail to: MacIE-Talk@lists.letterrip.com

[3]
http://www.w3.org/TR/REC-CSS2/visudet.html#containing-block-details

[4]
http://lists.w3.org/Archives/Public/www-style/2001Jul/0065.html
Received on Saturday, 4 May 2002 14:10:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:14 GMT