Centering a table in Firefox

I have a small table on one of my pages, and I would like it to be concentrated so that it encodes <table cellpadding="0" cellspacing="0" align="center"> , which works fine in IE, but the table still left alignment in Firefox.

If I use text-align:center n align:-moz-center does not work in IE

What do I need to change to get a table in Firefox Center? If I have to use -moz-center , how do I get it to work in IE?

I'm stuck here.

+4
source share
2 answers

As Lekenstein 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 style definition of width and margin .

+4
source

Add margin: auto; to the table. This is the standard way to do this.

+6
source

All Articles