Centering Tables

liunx

Guest
Until i learn the CSS I'm stuck using tables for layout. I know it is not correct but it is all I have until I learn the correct way to layout my webpage. Anyways, I have my page in a table. What I am trying to do is have it so that the table is always centered on the screen so users with different resolution sizes will all still see my table centered on the page.<br />
<br />
I tried to put the table in the <center> tag but that didn't work.<br />
Any suggestions on how to achieve what I described?<br />
<br />
Thanks,<br />
Dave<!--content-->You can try putting it into a div and then using margins.<br />
<br />
<style type="text/css"><br />
#div{margin:auto;}<br />
</style><br />
<br />
<div id="div"><table></table></div><!--content-->Try <table align="center"><!--content-->Originally posted by LeeU <br />
Try <table align="center"> <br />
If I am recalling correctly align is not a valid attribute. So you would want to use <table style="text-align:center;"><!--content-->Yeah, my first thought was <table align="center"> but neither that nor the other method mentioned using margins worked.<br />
<br />
Anyone else have a suggestion?<br />
<br />
-Dave<!--content-->I just tried <table style="text-align:center;"> and still no dice. Is this a commopn problem to not be able to center a table on a page?<br />
<br />
Thanks again,<br />
Dave<!--content-->Bulding on the margins idea, try<br />
<br />
CSS: <br />
table.middle { width: 700px; margin: 0 auto; }<br />
<br />
HTML:<br />
<table class="middle">...</table><br />
<br />
You can change the width and class names, it won't make much of a difference...<!--content-->Don't know if this will work or not <br />
<style type="text/css"><br />
table{margin:auto; text-align:center;}<br />
</style><!--content-->
 
Back
Top