Re: CSS to center a table?

That does not work in Netscape. Think outside the box and do not reply to
all that is very annoying on this list.

See the following message that is much better at the answer.

----- Original Message -----
From: "J. David Eisenberg" <catcode@catcode.com>
To: "Ches" <ches@io.com>
Sent: Monday, May 21, 2001 9:02 AM
Subject: Re: CSS to center a table?


> On Mon, 21 May 2001, Ches wrote:
>
> > I have found that nesting tables has produced the centering of the table
> > effect. This is bad coding however and I would recommend that a better
way
> > of aligning tables independently be found and used. The initial table
cell
> > needs to have something in it, either a blank image that is sized to the
> > width of your page or some text in order for the nested table to center.
> >
>
>   A much-publicized solution is posted at my website with a brief
> explanation.
>
>    http://catcode.com/csstips/center_table.html
>
> ---
> J. David Eisenberg  http://catcode.com/
>


Sincerely,
Franchesca Havas
McKinney, Texas

----- Original Message -----
From: "Manos Batsis" <m.batsis@bsnet.gr>
To: <www-style@w3.org>
Cc: "Ches" <ches@io.com>
Sent: Monday, May 21, 2001 9:40 AM
Subject: RE: CSS to center a table?


>
>
> You don't need three table cells:
>
>
>  <table style="width:100%;height:100%;text-align:center;border:1px solid
> #c0c0c0;">
>   <tr>
>    <td style="vertical-align:middle;">
>     <table style="text-align:left;border:1px solid blue;">
>      <tr>
>       <td>test</td>
>      </tr>
>     </table>
>    </td>
>   </tr>
>  </table>
>
> The problem is, "vertical-align" can only be applied to (from what I
> know of)  COL, IMG, SPAN, and TR/TD/TFOOT/THEAD/TBODY.
>
> Regards,
> Manos
>
> > -----Original Message-----
> > From: Ches [mailto:ches@io.com]
> > Sent: Monday, May 21, 2001 4:47 PM
> > To: www-style@w3.org
> > Subject: Re: CSS to center a table?
> >
> >
> > I have found that nesting tables has produced the centering
> > of the table
> > effect. This is bad coding however and I would recommend that
> > a better way
> > of aligning tables independently be found and used. The
> > initial table cell
> > needs to have something in it, either a blank image that is
> > sized to the
> > width of your page or some text in order for the nested table
> > to center.
> >
> > <TABLE border="2">
> >   <tr>
> >     <td>hhhhhhhhhhhhhhhhhhhhhhh</td>
> >   </tr>
> >   <tr>
> >     <td style="text-align: center">
> >       <table border="2">
> >      <tr>
> >     <td>test</td>
> >   </tr>
> >       </TABLE>
> >     </TD>
> >   </tr>
> > </table>
> >
> >
> > Sincerely,
> > Franchesca Havas
> > McKinney, Texas
> >
> > ----- Original Message -----
> > From: "Michael D. Crawford (by way of Al Gilman
> > <asgilman@iamdigex.net>)"
> > <crawford@goingware.com>
> > To: <www-style@w3.org>
> > Cc: "Michael D. Crawford" <crawford@goingware.com>;
> > <fahrner@pobox.com>
> > Sent: Saturday, May 19, 2001 10:30 AM
> > Subject: CSS to center a table?
> >
> >
> > > [redirected from www-talk -Al]
> > >
> > > Is there a way to use cascading stylesheets to center a table
> > > horizontally on a page?
> > >
> > > I can give offsets in absolute values or percentages from
> > the left or
> > > right, but my tables have different widths. I'd like each
> > table in my
> > > page to be centered no matter how wide or narrow it may be,
> > using the
> > > same class for such tables.
> > >
> > > What happens when I try using text-align on the table is
> > that the text
> > > in the tables cells is centered within the cells. I want
> > the cell text
> > > to be left justified but for the table to be centered as a whole.
> > >
> > > (Actually, checking other browsers, in Netscape 4.73 on
> > Linux nothing
> > > happens, and Mozilla 0.9 on the Mac I get the behaviour I
> > describe. I
> > > can't get Netscape on the Mac to pick up stylesheets from a
> > linked file.
> > > Internet Explorer 4.01 on the Mac does what I want. What's
> > the deal?)
> > >
> > > Here's my first attempt:
> > >
> > > In article.css:
> > >
> > > <!-- My CSS
> > > table.center {text-align: center}
> > > -->
> > >
> > > in my article:
> > >
> > > <table class="center">
> > > <tr><td>Some Text</td></tr>
> > > <tr><td>Some Longer Text</td></tr>
> > > </table>
> > >
> > > This comes out like the following, with the text centered
> > in the cells:
> > >
> > >
> > > Some Text
> > > Some Longer Text
> > >
> > > What I want is the following, with the text left-justified
> > in the cells
> > > but the whole table centered:
> > >
> > > Some Text
> > > Some Longer Text
> > >
> >
> >
>

Received on Monday, 21 May 2001 10:52:32 UTC