Isenção de responsabilidade: Este artigo foi gerado usando tradução automática.

As of 22 Nov 2025, the Markdown editor has been upgraded from v1.4.10 to v3.2.2. The toolbar, layout, icons, and editor structure remain unchanged.

How to center align a table in the Knowledge base

Prev Next
This content is currently unavailable in Portuguese. You are viewing the default (English) version.

By default, tables on the Knowledge Base site are left-aligned within the content area. If you want a table to appear centered on the page instead of sitting against the left edge, you can override this using Custom CSS. The change applies globally to all tables on the site.


When to use table centering

  • Narrower tables: when a table only spans part of the page width, a left-aligned table can look unbalanced. Centering gives it a more polished, intentional appearance.
  • Visual consistency: if other elements on the page (such as centered headings or images) are already centered, a centered table keeps the overall layout visually consistent.
  • Reader focus: centering draws the reader's eye to the table by placing it in the visual middle of the page rather than off to one side.
NOTE

This CSS change applies to all tables across your Knowledge base site. It is not possible to target individual tables using this method.

NOTE

New tables have Fit table to page width turned on by default. On larger screens, these tables continue to span the full page width, so this snippet centers only tables with that option turned off. On smaller screens, such as mobile devices, the snippet also applies to tables with Fit table to page width turned on, so they are sized to their content and centered. To learn more, see Tables.


Quick reference

table {
    width: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

How to center align a table

  1. In the Knowledge Base portal, go to Settings > Knowledge base site > Site customization > Custom CSS & JavaScript.

Knowledge base site settings page showing the Custom CSS and JavaScript option in the left navigation.

  1. Select the CSS tab and paste the following snippet:
table {
    width: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
  1. Click Save.

Outcome

Before

Tables render flush against the left edge of the content area.

After

Tables render centered within the content area, with equal space on either side.


Best practices

  • Remove conflicting width or margin rules first. If you already have other custom CSS targeting table (for example, a fixed width or different margin values), the centering snippet may not take effect, or may behave unpredictably, until the older rule is removed or the new one is placed after it in the CSS editor.
  • Combine with cell alignment if needed. This snippet only centers the table block. If you also want the text inside cells centered, add table td, table th { text-align: center; } alongside it.
  • Test with both narrow and wide tables. Centering is most noticeable on tables narrower than the page width. A table that already spans the full width looks the same either way.
  • Check how tables look on mobile. Tables with Fit table to page width turned on are not affected by this snippet on larger screens, but on smaller screens they are sized to their content and centered.