Tables

The most correct way to center a table is not with

margin: 0px auto 0px auto

but rather with

margin-left: auto; margin-right: auto;

The difference is that the first declaration [re-]sets the top and bottom margin of the table to 0px, which are not the default top and bottom margins of a table. This was correctly reported in March 2004 by M. Cowperthwaite here:

https://bugzilla.mozilla.org/show_bu...i?id=74952#c28

and it is also confirmed by an Apple Developer Connection article "Web Page Development: Best Practices"

and in How to center a Block Level Content with CSS by D. Dorward

and in Web Style Sheets CSS tips & tricks: Centering a block or image by W3C

and in CSS 1 horizontal formating (margin property) says: "if both 'margin-left' and 'margin-right' are 'auto', they will be set to equal values. This will center the element inside its parent."

GT

Document Tags and Contributors

Contributors to this page: GT
Last updated by: GT,