Thank you very much for the pointers. They clarify things a lot. But I
don't agree with the arguments given by Hixie, and feel that col
specifiers could be just handled as some equivalent CSS specifiers. See
below.
>
>> Opera and Internet Explorer (in standards mode) render the numbers
> > right-aligned.
>
> As far as I can see, this only applies to IE 7 and older. In standards
> mode, IE 8 and newer don't do that in standards mode (though in quirks
> mode, they do).
On the contrary, my finding is that IE8 honors the col specifier in
standards mode and not in quirks mode. Or perhaps I don't understand the
meaning of the menu option "tools -> compatibility view + compatibility
vew options" (sorry, rough translation of the labels in my Spanish IE8).
>
>> Is there any flaw in the markup?
>
> Not in terms of HTML, in this issue. But HTML specifications don't quite
> reflect the reality.
>
>> Is there an alternate simple markup that could
>> ensure proper alignment in most modern browsers?
>
> Yes, add align="right" to the cells you want to have right-aligned. It's
> simple, though not nice and convenient. In this case, when all cells
> should be aligned, you could use shorter markup by using the
> align="right" attribute in each <tr> element, not in each cell.
>
> Alternatively, you can keep what you have now (it handles some old
> browsers OK) and add the following style sheet, for modern browsers:
>
> <style type="text/css">
> th, td { text-align: right; }
> </style>
>
> This is very easy when all cells need to be right-aligned. If you wanted
> to align, say, only the data cells in the 3rd column, you would use
>
> td:nth-child(3) { text-align: right; }
Yes. And perhaps col specifiers like:
<table id="t0001">
<col align="left" />
<col align="center" />
<col align="right" />
can be automatically converted to some equivalent CSS2 rules:
table#t0001 > tbody > tr td {
text-align: left;
}
table#t0001 > tbody > tr > td + td {
text-align: center;
}
table#t0001 > tbody > tr > td + td +td {
text-align: right;
}
Or to CSS3 rules using :nth-child(), as you point out.
They certainly work in Firefox. See:
http://lml.ls.fi.upm.es/~mcollado/temp/tablealign2.html
So my question is: why FF ignores col specifiers, instead of converting
them to their equivalent CSS rules and apply the CCS rendering model?
IMHO this seems a FF bug.
We can do the translation explicitly, but it certainly would be very
nice if the browser did the translation itself.
Thanks you for your clarifications.