W3C home > Mailing lists > Public > www-style@w3.org > May 2001

RE: CSS to center a table?

From: Manos Batsis <m.batsis@bsnet.gr>
Date: Mon, 21 May 2001 19:00:53 +0300
Message-ID: <A35E2040C17F0C48B941B8F4D0DF122908E25F@ermhs.Athens.BrokerSystems.gr>
To: <www-style@w3.org>


> -----Original Message-----
> From: Ches [mailto:ches@io.com]

> That does not work in Netscape.

Um... "vertical-align" works great in N6. If you mean NN, that's not a
CSS compliant browser so you are probably in the wrong list.

> Think outside the box and do 
> not reply to
> all that is very annoying on this list.

Sorry but I cannot figure out what exactly you are trying to say, or who
is it you are trying to say it to. If you are talking about me posting
publicly, well, this may end up to some technical discussion after all.
Besides, the message I am replying to right now, was sent to
www-style@w3.org. But if I get this right, yes you are correct. There is
something annoying in this list and that's folks that ask HOWTO's. I
guess what's even worse is people like me posting to their help. Sorry.
Since I am a showoff and if you are interested in a *CSS compliant*
solution, you can use css positioning without having to use a single
table element. Just Ps will do (even with a DIV as a container).

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

The only thing I find in the following message is a link to a website. I
have mail, but my internet connection is down: server maintenance. Thus,
the message holds no answer for me.


Just take it easy.
Manos




> ----- 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 11:54:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:09 GMT