Simple question. Don't know about the answer though. This is what I use to center tables and it works, on Chrome at least.

<table  style="margin-left: auto; margin-right: auto;">

1 answer


For IE, you have to add style="text-align:center;" to your body tag. But then you'd have to add a style="text-align:left;" to make sure all your text isn't centered.

You're better off using a stylesheet instead of inline styles.

Put this in your head or in an external stylesheet:

<style type="text/css">
body {text-align:center;}
div, p /*add a comma-separated list here of any other elements that need left-aligned text*/ {text-align:left;} {margin-left:auto; margin-right:auto;}

Your table tag should then be this: <table class="center">

Answered about 6 years ago by Leslie N