As a followup to my discovery of what I believe is an error in the CSS box model, I've sent an e-mail to the editor of the CSS3 box model specification, reproduced below:
----- Original Message -----
From: "Keith Devens"
To: <bert @ w3 .org>
Sent: Friday, June 07, 2002 12:02 AM
Subject: CSS3 Box Model concern
Dear Mr. Bos:
Please forgive me if you're not the appropriate person to send these
comments to.
I have concerns about one aspect of the CSS3 box model. Specifically, how
the height of a box is computed when its height is specified in percentages
and the containing box's height is "auto". The specific verbiage in CSS3 [1]
is this:
"A <percentage> is relative to the computed value of the width or height of
the containing block, but if that value is 'auto' the computed value for the
percentage is also 'auto'."
and in CSS2 [2]:
"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'."
After trying very hard to create a specific layout and speaking to some
folks on #mozillazine, I've come to believe, and those I spoke to in
#mozillazine agreed, that this is an error in the spec [3]. This one error
makes it impossible to produce many layouts with CSS that are otherwise
achievable using tables, and I give an example of this in [3].
I believe a better approach would be to always have a percentage height be
calculated relative to the computed value of the containing box, rather
than "resetting" a specified percentage value back to 'auto' if the
containing box isn't given a fixed height. My only conjecture as to why the
spec was written this way was because of a concern about implementation
difficulty. I don't believe this is an issue, however, because the layout
calculations performed if percentage values were computed according to the
containing box's computed height are similar to other calculations the user
agent already has to perform in other areas of layout, specifically, with
tables. Those I spoke to in #mozillazine also agreed that this would not be
an implementation concern.
Furthermore, even though it would break strict compatibility with CSS2 if
this were changed in CSS3, the real effect would be negligible. This is
because specifying a percentage height on an element contained within a box
without a fixed height is currently meaningless in CSS2 and in the current
working draft of CSS3. Therefore, if the spec allowed percentage heights to
be computed according to the computed height of a containing box, the spec
would take away no existing capabilities, and would add a significant new
capability. Moreover, that change would remove a special case currently put
into the spec, and would make height calculations more consistent, more
intuitive, and more flexible for the stylesheet writer.
I hope I have been clear in explaining my concern. Do you agree with my
conclusions? Is there anything I'm neglecting to take into consideration?
Thank you very much for taking the time to consider this issue. Again, if
you are not the person I should be sending this to, I'd appreciate it if you
could get me in touch with the right person. If there is anything else I can
do, or if you have any questions, please feel free to e-mail.
Sincerely,
Keith Devens
References:
[1] http://www.w3.org/TR/2001/WD-css3-box-20010726/#the-ltlengthgt
[2] http://www.w3.org/TR/REC-CSS2/visudet.html#the-height-property
[3] http://www.keithdevens.com/weblog/?id1950
Feel free to post a comment below. Please see my comment policy.
Formatting Rules (No HTML):