Center aligning a table within DIV element

Define the CSS style in css file or header of the HTML page:

div.center {
text-align: center;
}

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

Here is the HTML (within BODY tag):


<div class="center">
<table><tr><td>Content in center aligned table</td></tr></table>
</div>

Leave a Reply

Your email address will not be published. Required fields are marked *