Centering a Table

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
   I have a simple (?) page that has only a table as its content (I
suppose I could do it some other way, but I'm unsure of how...).  I want
the table to be centered on the page.  It works with I.E., but fails
with other browsers (FF, SeaMonkey, etc.): it aligns on the left part of
the page.
   Apart from of the annoying differences with I.E. and other browsers,
what can I do to assure the table's data is centered on the rendered
page?  TIA

Re: Centering a Table

replace Q with c Mike Copeland wrote:
Quoted text here. Click to load it

Tables are block elements, you center blocks of smaller width within
other blocks by setting the left and right margins to "auto". You do not
use "text-align: center" that is for alignment of inline text....

table { margin-left: auto; margin-right: auto; }

Take care,

Re: Centering a Table

Quoted text here. Click to load it
   I tried that, but it doesn't change any of the rendering behavior:
I.E. works, but other browsers don't.  
   I also removed the "text-align: center", but that made I.E. fail,
   It seems I didn't understand your message: could you show what code
is to be changed and where to implement the changes?  TIA

Re: Centering a Table (Mike Copeland) wrote:

Quoted text here. Click to load it

You site cannot be seen because your hoster is checking your site.

"You see this page, because system administrator of is
currently checking this website for malicious content. This redirect
will be removed once we will finish manually checking all files on this
account. As far we check over 100 websites it can take about 2-4 hours
to complete. ... is a free web hosting provider and all free hosting
providers suffer from abusers. Around 5% of users signup here just to
start hacking or phishing website or make other damage. So, in order to
survive, we must monitor what our users are hosting.
We are sorry for inconveniences, but checking all content manually, it
is the only way to provide you with the most secure and reliable
service. If you have found any illegal website on our network, you can
report it here."

So *that* is the downside of this free service. We were discussing this
free service in another thread only a few weeks back.


Re: Centering a Table

Mike Copeland wrote:

[replaced attribute] Jonathan wrote:

Quoted text here. Click to load it

Then you are doing something wrong.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    " ">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta http-equiv="content-language" content="en-us">
<title>Centering blocks</title>
<style type="text/css">
table { margin: 1em auto; border: 1px solid #000; }
td { border: 1px solid #aaa; }

<tr><td>I am in the center of the browser window</td></tr>
<tr><td>Even works in IE6.x +</td></tr>

Take care,

Site Timeline