How to center a table correctly

  • Thread starter Tassilo S. Schweiger
  • Start date
T

Tassilo S. Schweiger

I want to make my homepages to be confirmed by http://validator.w3.org

Now, a problem appears: How can I center a table correctly? Because the
align="center" is not an attribute of <table> here.

In CSS, the "text-align: center;" matches to IE, but is not matching to
Opera and Firefox. Both browsers show the tables still left. Is there
another attribute to center a table in CSS*?

Thank you,
Tassilo

* I am sorry, I could not find any appropriate newsgroups for CSS.
 
D

David Dorward

Tassilo said:
Now, a problem appears: How can I center a table correctly? Because the
align="center" is not an attribute of <table> here.
http://dorward.me.uk/www/centre/

In CSS, the "text-align: center;" matches to IE, but is not matching to
Opera and Firefox.

That's a bug in IE. The text-align property centres inline content of block
elements - it shouldn't change the position of a table at all.
Both browsers show the tables still left. Is there
another attribute to center a table in CSS*?

There are no attributes in CSS. CSS has properties.
* I am sorry, I could not find any appropriate newsgroups for CSS.

comp.infosystems.www.authoring.stylesheets
 
C

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted to ideas.
Tassilo S. Schweiger said:
I want to make my homepages to be confirmed by http://validator.w3.org

Now, a problem appears: How can I center a table correctly? Because the
align="center" is not an attribute of <table> here.

In CSS, the "text-align: center;" matches to IE, but is not matching to
Opera and Firefox. Both browsers show the tables still left. Is there
another attribute to center a table in CSS*?

Thank you,
Tassilo

* I am sorry, I could not find any appropriate newsgroups for CSS.

This issue discussed in some detail here.

http://theodorakis.net/tablecentertest.html
 
T

Tassilo S. Schweiger


Thank you. Then probably the most suitable should be "margin-left/right:
auto".
That's a bug in IE. The text-align property centres inline content of
block
elements - it shouldn't change the position of a table at all.

In fact, there are a lot of bugs in IE. For editing a page, you should not
use IE. Because many mistakes are ignored. For viewing a page, it is somehow
better, I think... Because then, everything is correct, even if it isn't
really edited correctly ;-)
There are no attributes in CSS. CSS has properties.

I am sorry! My native language is german.

Ok, next time, I know. I only looked for "css".
David Dorward

Tassilo
 
C

Curtis

Tassilo S. Schweiger said:
Thanks to you, too. Seems to be a very common difficulty to handle that one
correctly...


Tassilo

Check my latest post on this subject. We needed a rock-solid
method which worked across the board and was applied to a
single element, not the table AND a div method.

We're trying <table style="margin-left: 15%; margin-right:
15%; width: 70%;"> and variations of that. It lacks the
flexibility of auto-sizing to the text, but so far it seems
to work well on every browser for our needs. By changing the
numbers, the table can be positioned left, right,
center--and everywhere in between.

I'd be glad to hear about any problems others might spot in
this approach.

--

Curtis

Visit We the Thinking
www.wethethinking.com
An online magazine/forum
devoted philosophical
thought.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top