Author
Message
DamonHD
Posts:6158
Moderator
Member since: 2006-11-30
:: Quote ::
Subject: Silly/basic HTML question
Hi,

On my latest site re-jig I got bitten again by an old bug/feature (IE only) that I think I solved before but can't remember how...

I want to centre a table on the page but leave the text in it uncentred. How?

This works in the obvious way in FF with <center><table ...>...</table></center> or <p align="centre">... but in IE the centring leaks into the content inside the table.

What am I doing wrong?

Rgds

Damon
October 11, 2008 10:49PM
Joshua
Posts:2831
Administrator
Member since: 2007-03-16
:: Quote ::
Subject: Re: Silly/basic HTML question
I just tried this:

<body>
<table width="600" border="0" align="center">
  <tr>
    <td>bla</td>
    <td>bla</td>
  </tr>
  <tr>
    <td>bla</td>
    <td><div align="center">centered within the table</div></td>
  </tr>
</table>
</body>

And I can't find anything wrong with it. Maybe I just don't understand the question right.
October 11, 2008 11:47PM
Troi
Posts:4431
Senior member
Member since: 2006-11-30
:: Quote ::
Subject: Re: Silly/basic HTML question
I'm sure Joshs' code works fine - and here's what I produced on a quick knock up that also appears to work fine:

<table border="1" width="50%" id="table3">
<tr>
<td width="50%" align="left">This is left</td>
<td width="50%" align="right">This is Right</td>
</tr>
<tr>
<td align="left">&nbsp;</td>
<td align="right">&nbsp;</td>
</tr>
</table>
October 12, 2008 08:01AM
James
Posts:1757
Moderator
Member since: 2006-11-29
:: Quote ::
Subject: Re: Silly/basic HTML question
Looking at both tables on the same page using IE8 on XP I can see that Josh's table is centred on the page, and Troi's isn't.

Troi's code shows left and right justification in the left and right cells, and Josh's shows centred text in the bottom right cell.
October 12, 2008 08:44AM
DamonHD
Posts:6158
Moderator
Member since: 2006-11-30
:: Quote ::
Subject: Re: Silly/basic HTML question
Hi

I failed to make myself at all clear, sorry!

I want the table itself to be centred on the page (it is not the full width of the page), but the text *in* the table left justified, preferably not having to explicitly left justify every ***)()% cell individually!

Rgds

Damon
October 12, 2008 10:45AM
James
Posts:1757
Moderator
Member since: 2006-11-29
:: Quote ::
Subject: Re: Silly/basic HTML question
No, I think what you said was clear. Using Josh's layout, in the first cell I can type loads of text enclosed by <p></p>, then anoher load of text enclosed by <p></p> again and the result is that the table itself is centred on the page (widescreen) and the two paragraphs are left justified with no further code.

Going to the second cell, and repeating produces the desired result - left justified text within a centred table.

I've found this always works for me. I know people tend to prefer css nowadays, but tables do work and seem to work with more browsers reliably than css.



Edited 1 time(s). Last edit at 10/12/2008 11:28AM by James.
October 12, 2008 11:26AM
DamonHD
Posts:6158
Moderator
Member since: 2006-11-30
:: Quote ::
Subject: Re: Silly/basic HTML question
OK, I'll have another play. Thanks!

Damon
October 12, 2008 07:55PM
DamonHD
Posts:6158
Moderator
Member since: 2006-11-30
:: Quote ::
Subject: Re: Silly/basic HTML question
Harrumph! Still seems steam-powered <center> is irreplaceable for some things and a damn nuisance for others...

But I'm closer: thanks for the help!

Rgds

Damon
October 14, 2008 08:51PM

Sorry, you do not have permission to post/reply in this forum.