467,907 Members | 1,097 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,907 developers. It's quick & easy.

Center Tables with CSS

Hi,

I have a very crazy problem with CSS. I have tried to center my tables
with
TABLE {margin-left:auto; margin-right:auto}
how it is described in many other postings.
Mozilla and Konqueror are accepting this way of centering the table
but not IE.
I also tried
TABLE {margin-left: 0 auto}
which I have seen recently, too. But nothing works.

Had anyone the same problem and can help me. If not, I have to center
the tables with the "align" attribute. But if it's possible I want to
avoid that.

Bye

Bastian
Jul 20 '05 #1
  • viewed: 2537
Share:
6 Replies


Bastian wrote:
I have a very crazy problem with CSS. I have tried to center my tables
with
TABLE {margin-left:auto; margin-right:auto}
how it is described in many other postings.
Mozilla and Konqueror are accepting this way of centering the table
but not IE.


I think IE6/Win should do the right thing with that CSS if you make sure
your document is rendered in CSS standards-compliant mode
http://msdn.microsoft.com/library/de...hancements.asp
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Els
Bastian wrote:
Hi,

I have a very crazy problem with CSS. I have tried to center my tables
with
TABLE {margin-left:auto; margin-right:auto}
how it is described in many other postings.
Mozilla and Konqueror are accepting this way of centering the table
but not IE.
I also tried
TABLE {margin-left: 0 auto}
which I have seen recently, too. But nothing works.

Had anyone the same problem and can help me. If not, I have to center
the tables with the "align" attribute. But if it's possible I want to
avoid that.


For IE5 (and 4) you will need the center:align; property in
the style of the parent element.
http://locusmeus.com/html-css/centeringpage.html is about
centering a page, but the same principle goes for tables,
I'd think.

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -

Jul 20 '05 #3
Bastian wrote:
I have a very crazy problem with CSS.
comp.infosystems.www.authoring.stylesheets is a couple of doors along, this
is the html authoring newsgroup.
I have tried to center my tables
with
TABLE {margin-left:auto; margin-right:auto}
how it is described in many other postings.
Mozilla and Konqueror are accepting this way of centering the table
Yup, they are good browsers.
http://dorward.me.uk/www/centre/#block
but not IE.
You are probably using an obsolete version of IE, or are failing to trigger
standards mode.

http://dorward.me.uk/www/centre/#ie explains the work arounds.
I also tried
TABLE {margin-left: 0 auto}


This means the same as:

margin-top: 0;
margin-bottom: 0;
margin-left: auto;
margin-right: auto;

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #4
David Dorward <do*****@yahoo.com> wrote:
I also tried
TABLE {margin-left: 0 auto}


This means the same as:

margin-top: 0;
margin-bottom: 0;
margin-left: auto;
margin-right: auto;


Margin-left only takes one value, correct usage: "margin:0 auto".

--
Spartanicus
Jul 20 '05 #5
Els
Spartanicus wrote:
David Dorward <do*****@yahoo.com> wrote:
I also tried
TABLE {margin-left: 0 auto}


This means the same as:

margin-top: 0;
margin-bottom: 0;
margin-left: auto;
margin-right: auto;


Margin-left only takes one value, correct usage: "margin:0 auto".


I just looked at this sentence of yours, and the code above,
and again, and once more.. and then I saw the difference.

Funny how you see what you're expecting to see, while it's
not really there ;-)

--
Els
http://locusmeus.com/
Sonhos vem. Sonhos vo. O resto imperfeito.
- Renato Russo -

Jul 20 '05 #6
Spartanicus wrote:
Margin-left only takes one value, correct usage: "margin:0 auto".


Whoops - misread the previous post.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 20 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Campbell's List | last post: by
3 posts views Thread by Bastian | last post: by
3 posts views Thread by scoffer | last post: by
14 posts views Thread by gaijinco | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.