Title: How do I center a table on the page?
Author: Tobias Bäthge
Published: December 2, 2012
Last modified: May 14, 2025

---

Back to: [Frequently Asked Questions](https://tablepress.org/faq/?output_format=md)•
[Documentation](https://tablepress.org/documentation/?output_format=md)

# How do I center a table on the page?

Normally, tables extend to the full width of the container element they are added
to. Sometimes, for tables with few columns, it might however look better to reduce
the table’s width and center it on the page. This can be done with the some CSS 
code that needs to be added to the “Custom CSS” textarea on the “Plugin Options”
screen of TablePress:

    ```language-css
    .tablepress-id-N {
    	width: auto;
    	margin: 0 auto 1em;
    }Code language: CSS (css)
    ```

If you have enabled the [Table Features for Site Visitors](https://tablepress.org/faq/documentation-datatables-javascript-library/)
for the table, please use this instead:

    ```language-css
    #tablepress-N_wrapper {
    	width: 80%;
    	margin: 0 auto;
    }Code language: CSS (css)
    ```

In both cases, the `N` needs to be changed to the ID of the table in question (or
use `.tablepress` as the first part of the selector, if you want this to apply to
all TablePress tables on your site).