W3C home > Mailing lists > Public > www-style@w3.org > November 2011

Re: [CSS21] 17.5.2.1 Fixed table layout and percentages

From: Simon Sapin <simon.sapin@kozea.fr>
Date: Thu, 17 Nov 2011 14:33:19 +0100
Message-ID: <4EC50D1F.1040801@kozea.fr>
To: www-style@w3.org
Thanks Gérard for the many clarifications.

Le 17/11/2011 00:14, "Gérard Talbot" a écrit :
> This reference (algorithm of 10.3.3 for blocks) of the spec (recourse of
> algorithm of 10.3.3) is not implemented in any browser I know of.

So as the spec says, when the width is auto, the automatic layout should 
be used instead. However the automatic layout is not specified and UAs 
can do anything the want … including the fixed layout. I’ll do that at 
first until I implement some kind of automatic layout.

> [snip]

Ok for containing blocks and what percentages refer to.

> " (...) percentage is calculated with respect to the height|width of 
> the generated box's containing block. If the height|width of the 
> containing block is not specified explicitly (i.e., it depends on 
> content height|width), then the value computes to 'auto'. " or a 
> sentence typically similar. 

The width of a table always depend on its content. (Even a non-auto 
width property is actually a minimum.) Does that mean that percentage 
widths on columns or cells can never be used?

>> The remaining space is then divided for columns that do not have a width
>> yet. The remaining space is the tentative width minus everything else.
> Everything else being: table borders and column borders and cell borders
> and border-spacing.

Paddings are not listed here. I guess that the used width of a cell is 
the column width minus the left and right cell padding? So the `width` 
property on cells (of the first row) represents the content width plus 
paddings, unlike other boxes where it is just the content box?

>> (The used width is still not known.) Now what happens if this result is
>> negative or zero? Is the width of the remaining columns zero or some
>> other arbitrary value?
> I assume here that your questions refer to column(s) being set to a
> percentage value.
>
> If it's zero, then remaining columns get zero width. If it's negative,
> then it's resulting layout is undefined. It's like a situation where a
> column width would be set to be 110% of table box width.

It can happen without percentages. Example: a 3-column table with

table { width: 300px }
#first_column, #second_column { width: 200px }
/* No specified width for the third column */

Or even with percentages that sum under 100%:

table { width: 300px }
#first_column { width: 200px }
#second_column { width: 50% }
/* No specified width for the third column */

What is the width of the third column?

If such cases are undefined, can UAs do whatever they want? I’d say the 
most sensible thing to do give a zero width to remaining columns.

> [snip]
> What your post does not mention - and this can be a real headache - is
> that 'table-layout: fixed' can apply to 4 types of tables:
> 1- HTML<table>  with border-collapse set to separate
> 2- HTML<table>  with border-collapse set to collapse
> 3- CSS table with border-collapse set to separate
> 4- CSS table with border-collapse set to collapse
>
> and table-layout: fixed covers several possibilities itself: when table
> has an absolute width (eg: table {width: 300px;}), when table has a
> relative width (eg: table {width: 40%;}), when table has an auto width.
> When table has an auto width, then there are sub-categories of
> possibilities too: if one column has a set width (with relative or
> absolute width) or if one table cell in first row has a set width
> (non-auto absolute width), etc... The whole thing can get quite long and
> complex to test.

Does it matter if a table is made of HTML table elements or not as long 
as the elements have the right table-* values for `display`? (Apart from 
span/colspan/rowspan attributes.)

Regards,
-- 
Simon Sapin
Received on Thursday, 17 November 2011 13:33:57 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:46 GMT