Forum Moderators: not2easy

Message Too Old, No Replies

Centering whole a tables site using CSS possible?

Need to center my layout made with tables, left aligned

         

silverbytes

1:16 pm on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My site is made in tables and aligned to left. I'd like to wrap my hole site with a div or something to make it be centered in horizontal. Like putting in a box 1px width the whole content and perfectly centered (to work in IE and FF)

Is that possible?

Dabrowski

1:41 pm on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming your <table> immediately follows your <body>, the followng should work....

BODY { text-align: center; } /* Only IE6 needs this */

TABLE {
margin 0 auto; /* Technically correct way to centre a block */
text-align: left; /* To counter the body text-align */
}

Now assuming your <table> isn't set to 100% width, that should work.

centime

1:51 pm on May 10, 2007 (gmt 0)

10+ Year Member



hi Dabrowski

I tried similar code, it worked in firefox, but not in IE6

Thanks for your help the other time

cheers

Dabrowski

3:06 pm on May 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



np centime, but this way DOES work in the big 3.

Check out this thread, where I used this technique myself to centre some info boxes. Lots of variations on the theme too!

[webmasterworld.com...]

I also have a test page demonstrating all methods, sticky me for the address.