Click to See Complete Forum and Search --> : Centering Table data


screaming_banjo
09-25-2003, 04:52 AM
Hi

I would like table data to be aligned to the center. I know that I can keep typing:

<td align="center">

for every table cell, but thought there must be an easier way than this. I've tried styles using this:

td {align: center;}

and

td {text-align: center;}

but neither have worked, any help would be most appreciated!

96turnerri
09-25-2003, 04:59 AM
<td width="33%">
<p align="center">WHATEVER</p>
</td>

Charles
09-25-2003, 05:37 AM
Originally posted by 96turnerri
<td width="33%">
<p align="center">WHATEVER</p>
</td> Back in 1997 the "width" attribute was depricated for all but the IMG element and the "align" attribute depricated for all but TH and TD elements.

<!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">
<!--
td {text-align:center}
-->
</style>

<table summary="Some data">
<tr>
<th>&nbsp;</th>
<th>Heading</th>
<th>Heading</th>
<th>Heading</th>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
<tr>
<th>Heading</th>
<td>Data</td>
<td>Data</td>
<td>Data</td>
</tr>
</table>

96turnerri
09-25-2003, 06:30 AM
o and cos thats so much easier isnt it