Question Centering a table using CSS

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I have a table in my page that I want centered horizontally. The table is inside a td tag, and everything else in that td tag is getting centered. Here is my current code:

<td style="text-align:center;">
<table>

I realize I could put the table in a div to align it, but if possible I would like to avoid any extra tags, and I would have thought that there would be some way to center a table if everything else is getting centered as well (not to mention I seem to remember my current code working in previous versions of IE, I am currently using IE8). Does anybody know of a way to center the table without adding any extra tags, or is a div my only choice? Thanks.
 
Personally I've used <center></center> but then that's an extra tag, that you don't want.

However, a quick google has produced CSS Horizontal Align - not tried it, but it could be your answer.
 
Back
Top