Page is a not externally linkable
- Code, Content, and Presentation
-- CSS
---- Center the middle column in a 3-column table?


Tonearm - 5:19 am on Jan 1, 2013 (gmt 0)


Do you mean that the two side columns might be different widths, so you can't do it simply by centering the entire table?

I'm actually not concerned about the widths of the two side columns as long as the middle column is centered.

I've tried this:

<table style="margin-left:auto;margin-right:auto;width:auto">
<tr>
<td style="text-align:right">left side text</td>
<td style="width:100px"><img src="/image.jpg" width="100" /></td>
<td style="text-align:left">right side text</td>
</tr>
</table>

The 100px-wide image sits slightly right of center.


Thread source:: http://www.webmasterworld.com/css/4532264.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com