Hyper Text Markup Language (HTML) Question:

How do I center a table?

Tweet Share WhatsApp

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;
}

Download HTML PDF Read All 84 HTML Questions
Previous QuestionNext Question
How do I align a table to the right (or left)?How can I check for errors?