How do you center a table in FireFox?

User 2176507 Photo


Registered User
214 posts

I have used the tags <center> </center> and my table centers fine in IE but not FireFox. How do I get a table to center in FireFox?

Thanks in advance for any help,
yeto
User 2176507 Photo


Registered User
214 posts

I searched on the internet for a solution and found this code but I do not know where to place it or if it would even work.

body {
text-align: center;
text-align: -moz-center;
}

Thanks,
yeto
User 2176507 Photo


Registered User
214 posts

I also found this code but again I don't know how to use it.

table.center {
margin-left:auto;
margin-right:auto;
}

<table class="center">
...
</table>

body {text-align:center;}

Thanks,
yeto
User 1948478 Photo


Senior Advisor
1,850 posts

The html tag <center></center> is not supported in HTML5, which may be the reason for your problem. The centering is instead best handled by CSS.
I get the impression from your posts ( ;) ) that you are probably not using any external CSS, so a quick and simple way would be to use an in-line style:

<table style="margin:0 auto;">
<tr>
<td>
centered text
</td>
</tr>
</table>


This is essentially a compact version of what you have in your last post, with the addition of "0" for top and bottom margins, which you can change as needed...

Check this out for reference:
http://www.w3schools.com/cssref/pr_margin.asp
User 2176507 Photo


Registered User
214 posts

I am using VSD so it is my understanding that I could enter css code in the header tag if that would be easier. I posted my question here instead of the VSD forum because I felt like people here would have more insight related to code.

I have both the registered/paid versions of VSD and Html Editor.

Would it be easier to enter css code in the header tag versus in-line style?

Thanks in advance for any additional help,
yeto
User 1948478 Photo


Senior Advisor
1,850 posts

Yes, it would be best to put the style in the head section:

<head>
........
<style>
table.center {margin:0 auto;}
</style>
.......
</head>


and then the class for the table in the body section:

<body>
......
<table class="center">[...content here...]</table>
......
</body>

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.