Forum Moderators: not2easy

Message Too Old, No Replies

Problem centering a table

I have tried both of the common solutions and it still doesn't work

         

timyang

3:22 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Hi

I have a site that I am working on at [brandprism.com...]

The layout forms within a table (sorry! I haven't converted the whole thing to fully css yet). And I'm trying to center it.

I am currently using the margin-left: auto and margin-right: auto CSS properties in the table. And it works fine for Firefox and Mac IE. But it doesn't work for any version of Windows IE. In that browser, the layout is flushed to the left of the screen.

I have also tried text-align: center in the body and text-align: left in the table. But that hasn't worked either.

Can someone please tell me:

1) why this is occuring (it doesn't make any sense to me)
2) and how I can center this table

Thanks for considering my problem!

Tim

Longhaired Genius

3:27 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



"margin: auto" will work for IE6 if you add a valid DOCTYPE to the top of your pages. That just leaves IE5 and earlier, and, personally, as their share of the market is getting smaller day by day, I don't worry if their tables look a bit wonky as long as the information they contain can be read.

timyang

6:04 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



LG, there is a valid doctype. It's XHTML transitional. But the problem is still with IE6. It was tested on the XP version and the layout is still left justified. Is there anything else I should look into?

Tim

Span

6:45 pm on Dec 15, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<table width="100%" border="0" cellspacing="0" cellpadding="0" id="environment">
<tr>
<td width="744">

Tim, your table has a 100% width (try centering that) and the only cell in the first row is 744 px. I'm not using Windows, but what if you change the 100% width in 744?

And by the way, did you read the T.O.S.? Posting URLs is not allowed here..

timyang

6:50 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Sorry about the URL, Span. I wasn't aware of that rule.

Originally, it was 744 and it didn't work. Which is why I changed it to 100%. I think it still doesn't work.

I'm just not sure what is causing the table to stick to the left side of the screen.

Do you have any idea why?

Longhaired Genius

7:04 pm on Dec 15, 2004 (gmt 0)

10+ Year Member



Ah. It definitely works with a strict html 4 doctype, which is what I try to use:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

You'll have to experiment and find a doctype both you and IE6 can live with.