Log in

View Full Version : text-align: center not working on table



gib65
01-05-2015, 05:44 PM
I've got a table inside a div like so:

<div style="text-align: center; padding-top: 3.5em;">
<table>
...
</table>
</div>

The div spans the entire page. The table takes up about 1 fifth of the div width. Yet my div CSS is not working. The table is still left-aligned (the top padding is ok).

Does anybody know why my table won't center?

Beverleyh
01-05-2015, 06:46 PM
Try <table style="margin:auto"> instead.

If you need more help, please provide a link to your web page.

gib65
01-05-2015, 07:57 PM
Thanks, Bev, that worked.