views:

47

answers:

2

I've got a small table on one of my pages and I'd like it centered so have coded 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?n If i should use -moz-center how to make it work in IE

I m stuck here ..thanks a lot in advance

+4  A: 

Add margin: auto; to the table. That is the standard way to do it.

Lekensteyn
+3  A: 

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.

Jakub
This won't work unless the div has a set width. By default, block level elements have a width of 100%.
Brian Ray