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

Percentage heights and the ICB

From: Andrew Clover <and@doxdesk.com>
Date: Sat, 4 May 2002 13:12:02 +0000
To: www-style@w3.org
Message-ID: <20020504131202.A4475@doxdesk.com>
RSL <swim@catholic.org> wrote on webdesign-l:

> ie5 mac [...] does *not* like a percentages with the top
> property.

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.

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%;'.

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.

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

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. 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.

> 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.)

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.

Andrew Clover
Received on Saturday, 4 May 2002 09:17:52 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:27:01 UTC