Nick said:
That's all good CSS except for internet explorer won't do it. You'll also
have to do something like, surround the table in a DIV with "text-align:
center" which will make ie center the contents in the window, and then add
"text-align: left" so that the text centering doesn't cascade down to the
text inside the table. There's other ways like adding a negative margin but
i think this is the simpelst best way.
All he has to do is remove the xml declaration. MSIE 6 for windows
expects to see the doctype declaration (which can trigger standards
compliant rendering mode) at the very first line of a document. Here,
the xml declaration creates a conflict; it's really an MSIE 6 bug.
"An XML declaration is not required in all XML documents; however XHTML
document authors are strongly encouraged to use XML declarations in all
their documents."
http://www.w3.org/TR/2002/REC-xhtml1-20020801/#strict
11.3 Table formatting by visual user agents
11.3.2 Horizontal and vertical alignment
Inheritance of alignment specifications
"The default alignment for cells depends on the user agent. However,
user agents should substitute the default attribute for the current
directionality (i.e., not just 'left' in all cases)."
http://www.w3.org/TR/html401/struct/tables.html#h-11.3.2.1
If you insert the "direction:rtl;" css rule to the body or html tag,
you'll see that not only the text is formatted from right to left but
the horizontal alignment formating is right aligned as well.
W3C CSS level 1
4 Formatting model
4.1.2 Horizontal formatting
"(...) if both 'margin-left' and 'margin-right' are 'auto', they will be
set to equal values. This will center the element inside its parent."
http://www.w3.org/TR/REC-CSS1#horizontal-formatting
W3C CSS level 2
10 Visual formatting model details
10.3.3 Block-level, non-replaced elements in normal flow
"If both 'margin-left' and 'margin-right' are 'auto', their computed
values are equal."
http://www.w3.org/TR/REC-CSS2/visudet.html#q6
Interactive complete demo on table alignment (table, cell, text
direction, row, column, caption):
http://www10.brinkster.com/doctorunclear/HTMLJavascriptCSS/DynamicTableFormatting.html
As others mentioned, if you want to format the horizontal alignment of
data inside cells, then use the CSS property text-align:[left|center|right]
E.g.: table {text-align:left;}
DU