Displaying tables through the WordPress text editor is a time-consuming task and frankly, not many functionalities are available. You definitely can create a complex table but for that, you should be very good at coding.  If you are a regular reader of my blog, you must be aware by now that I am not really a typical coder,  so I prefer to create simple tables. Still, there are certain basic formatting requirements (such as to align the table) that I need to accommodate so that the table can blend with the format of my blog. I have explained below the simplest method to center a table in WordPress.

How Does WordPress Align a New Created Table?

Let us start by adding a simple table from WordPress. You can check out how to create a table using WordPress to understand the steps involved in creating and formatting a table.

A B
Apple Barbecue

When you check the ‘Text’ table of your WordPress Classic Editor (I do not use Gutenberg yet), you will see the following table code gets added when the table is created.

<table>
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>Apple</td>
<td>Barbecue</td>
</tr>
</tbody>
</table>

Unfortunately, the table gets automatically aligned to the left of the post or page. Now if that is not a big deal to you then this format will work for you but if you are someone like me who has to center all images, tables, embedded links, etc on a post then you will have to learn how to center this table.

What Happens When You Try to Center Format the Table through WordPress Text Editor?

If you try to highlight the table to left, center, or right justification then you will notice that only the highlighted text inside the table moves but not the table itself.

In the table below, I have tried to center it by highlighting the table but as you can see only the text alignment has changed and not the overall table.

A B
Apple Barbecue

As the code shown below indicates that only the text aligns to the center, not the table.

<table border="0">
<tbody>
<tr>
<td style="text-align: center;">A</td>
<td style="text-align: center;">B</td>
</tr>
<tr>
<td style="text-align: center;">Apple</td>
<td style="text-align: center;">Barbecue</td>
</tr>
</tbody>
</table>

How do You Center a Table Between the Margins of the Post?

Here comes the use of a simple change in the table command in the first line of the code. We just need to add an align=center which will center the entire table between the margins of the post.

<table border="0" align="center">
<tbody>
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>Apple</td>
<td>Barbecue</td>
</tr>
</tbody>
</table>

Which aligns the table in the center as shown below.

A B
Apple Barbecue

Hopefully, the above trick will help you center your table in WordPress. If you have further queries or an easier approach to the same, please send it in comments below and I will make sure to respond to all of them.