Reputation: 10626
I have a table in my html that I would like to center on my page. I have the following code. I is perfectly find in ie but not in chrome. Am I doing something wrong?
<table align="center">
<tr>
<td>
<div class="zoom_controls"> </div>
</td>
</tr>
</table>
Upvotes: 1
Views: 4675
Reputation: 10820
Give the table a fixed width, if possible.
Give the table a top- and bottom-margin of 0 (or other if you want to) and a left- and right-margin of auto.
This works with every kind of element with a known width.
You can also use a variable width (em / %).
EDIT: seems like other were typing the same solution as me.
Upvotes: 0
Reputation: 207901
The align="center"
syntax was deprecated a long time ago. Add margin:0 auto
to your table:
table {
margin:0 auto;
}
jsFiddle example (border added for visibility)
Upvotes: 5