Click to See Complete Forum and Search --> : Centering a table?


deep
09-12-2003, 04:15 PM
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!

PeOfEo
09-12-2003, 04:19 PM
<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.

Charles
09-12-2003, 04:24 PM
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>&amp;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>

deep
09-12-2003, 05:09 PM
Thanks

PeOfEo
09-13-2003, 02:34 AM
No prob
did either of our two methods work for you?