Hyper Text Markup Language (HTML) Question:
How do I center a table?

Answer:
In your HTML, use
<div class="center">
<table>...</table>
</div>
In your CSS, use
div.center {
text-align: center;
}
div.center table {
margin-left: auto;
margin-right: auto;
text-align: left;
}
<div class="center">
<table>...</table>
</div>
In your CSS, use
div.center {
text-align: center;
}
div.center table {
margin-left: auto;
margin-right: auto;
text-align: left;
}
Previous Question | Next Question |
How do I align a table to the right (or left)? | How can I check for errors? |