W3C home > Mailing lists > Public > public-css-testsuite@w3.org > August 2012

Re: Percentage Height of a Replaced Element in a Table Cell

From: Gérard Talbot <css21testsuite@gtalbot.org>
Date: Tue, 7 Aug 2012 17:44:08 -0400
Message-ID: <891a8316e2ef1ea80ed18628533f866f.squirrel@ed-sh-cp3.entirelydigital.com>
To: "Robert Hogan" <lists@roberthogan.net>
Cc: public-css-testsuite@w3.org

Le Mar 7 août 2012 17:19, Robert Hogan a écrit :
> Hi CSS Test,
> Browsers disagree on how to render this snippet:
>         <table style="width:20px;height:20px">
>             <tr>
>                 <td style="width:100%;height:100%"><img
> src="50x50.png"></td>

In your snipped, the percentage is applied onto the table cell and not
on the replaced element.

CSS 2.1 does not define how the height of table cells and table rows is
calculated when their height is specified using percentage values.
17.5.3 Table height algorithms

>             </tr>
>         </table>
> WebKit, FF: the image is rendered as 50x50

Table and table cells' default overflow property is set to visible. So,
the 50x50 image should be visible regardless of the dimensions of the

Overflow applies to table cell. IIRC, overflow also applies to table boxes.

> IE, Opera: the image is rendered as 20x20
> I believe IE and Opera are correct here: "The percentage is calculated
> with
> respect to the height of the generated box's containing block." Going up
> the chain this is 20px.

Width for table when resorting to 'table-layout fixed' algorithm (for
both border-collapse models):

"The width of the table is then the greater of the value of the 'width'
property for the table element and the sum of the column widths (plus
cell spacing or borders). If the table is wider than the columns, the
extra space should be distributed over the columns.
" Fixed table layout

Robert, it would be best to create a full, accessible testpage from your
snippets and to use+declare 'table-layout: fixed'.

> This is distinct from the following case, where rendering 50x50 would be
> the right thing to do:
>         <table>
>             <tr>
>                 <td style="width:100%;height:100%"><img
> src="50x50.png"></td>
>             </tr>
>         </table>
> "If the height of the containing block is not specified explicitly
> (i.e.,
> it depends on content height), and this element is not absolutely
> positioned, the value computes to 'auto'."

One important question is: what is the containing block of a table cell?
Does the concept of containing block apply to table cell?


> Am I right in thinking this?
> Thanks,
> Robert

Contributions to the CSS 2.1 test suite:

CSS 2.1 Test suite RC6, March 23rd 2011:

CSS 2.1 test suite harness:

Contributing to to CSS 2.1 test suite:
Received on Tuesday, 7 August 2012 21:44:39 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:13:24 UTC