Reputation: 19537
I've got a small table on one of my pages and I'd like it centered so have coded <table cellpadding="0" cellspacing="0" align="center">
which works fine in IE but the table still left aligns in Firefox.
If i use
text-align:center n align:-moz-center
its not working in IE
What do I need to change to get the table to center in Firefox? If I should use -moz-center
how to make it work in IE?
I'm stuck here.
Upvotes: 4
Views: 3073
Reputation: 20475
As Lekensteyn mentioned, here is some code to show it in action:
<div style="margin: 0 auto; text-align:center;">
<table border="1" style="width:200px;">
<tr>
<td>Hello</td>
<td>How</td>
</tr>
<tr>
<td>are</td>
<td>you?</td>
</tr>
</table>
</div>
it should center itself based on the width
& margin
style definition.
Upvotes: 4
Reputation: 66505
Add margin: auto;
to the table. That is the standard way to do it.
Upvotes: 6