The purpose is to find the best way to align all cells in a column to the right. In the test tables, the first column should not be affected but the second column should be right-aligned.
align="right"
in all cells of the columnThis is most probably the most certain way, but it's clumsy. And it's not Strict.
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
<col align="right">
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
style="text-align:right"
in all cells of the columnThis probably works on all CSS enabled browsers, but it's clumsy.
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
<col style="text-align:right">
It seems that according to clause
17.3 Column selectors of the CSS2 specification,
this actually should not work, since text-align
is not one of the properties that apply to columns.
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
<col>
with a class and separate style sheetThe markup has <col class="num">
and
the style sheet contains .num { text-align: right }
.
This would let us use a separate style sheet instead of an
embedded one. (In this test, the separate style sheet is in
a style
element, but naturally it could, and normally
should, be in a separate file.)
Clause
Inheritance of alignment specifications (!)
in the HTML 4.01 specification seems to imply that
the style
attribute is to be inherited.
It's really an en passant statement:
"The order of precedence (from highest to lowest) for
the attribute valign
(as well as
the other inherited attributes
lang
, dir
, and
style
) is - -".
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
class
attribute in all cells of the columnThis uses <td class="num">
for all cells of
the column, with the style sheet as above.
This probably works on all CSS enabled browsers, complies with Strict rules and complies with the principle of using a separate (not embedded) style sheet, but it's clumsy.
Hello world | 42 |
Foo bar | 1 000 000 |
Zap | 123 |
On Windows 98, Internet Explorer 6.0 shows all the tests with the second column right-aligned.
On Windows 98, Netscape 4.51 shows the tests that
are not based on a col
element
with the second column right-aligned.
The same applies to Mozilla 1.2.1
and Opera 6.03.
On Unix, Lynx version 2.8.4 shows the first two tests with the second column right-aligned.