Centering a table?

liunx

Guest
Hello,

Im trying to center a table on my page... but i can not find a good way to do it in css?

I can not use <center></center> or <div align="center"> because the contents in that table will also be centered and that is no good.

If I write <table aligt="center"> then it centers the table but only in IE and not in Netscape...??

Please help!<table style="position:absolute;left:50%; width:500px; margin-left:-266px;"
the margin left needs to be a - half of your width for this to work properly.The CENTER element and the "align" attribute were both depricated in 1997.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example</title>

<style type="text/css">
<!--
table {border:solid 1px #a00; margin:auto}
-->
</style>

<table summary="some data illustrating some relationships">
<thead>
<tr>
<th>&nbsp;</th>
<th>Heading</th>
<th>Heading</th>
<th>Heading</th>
</tr>
</thead>
<tbody>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
</tbody>
</table>ThanksNo prob
did either of our two methods work for you?
 
Back
Top