Skip to content

Markdown Table Alignment: Left, Center and Right

By MarkdownTables.com editorial teamUpdated

On this page

How do I align columns in a Markdown table?

Alignment lives in the second line of the table, the delimiter row. Each delimiter cell controls the column above and below it.

Delimiter cell → resulting alignment
Delimiter cellResultUse it for
:---Left-alignedNames, descriptions, code, anything people read left to right
:---:CenteredShort fixed-width values: status icons, ✅/❌, country codes, HTTP status codes
---:Right-alignedNumbers: prices, counts, percentages, file sizes
---No alignment set; the stylesheet decides (body cells usually left)Default text columns
All four delimiter styles in one table
Markdown
| Default | Left    | Center  | Right    |
| ------- | :------ | :-----: | -------: |
| text    | text    | text    | 9.99     |
| longer text | longer text | longer text | 1,024.00 |
Preview
DefaultLeftCenterRight
texttexttext9.99
longer textlonger textlonger text1,024.00

If you'd rather click than type colons, the Markdown table generator has an alignment toggle on every column and writes the delimiter row for you.

Alignment rules worth knowing

  • Only the colons count. :-: and :-----------: both center. GFM needs one hyphen per cell; GitHub Docs suggest three for readability.
  • No space between colon and hyphens. Spaces around the cell are fine (| :---: |), but : --- or --- : is not a valid delimiter, and the whole table stops rendering.
  • Alignment is per column. The header cell follows the same alignment as the data. There is no per-row or per-cell syntax.
  • Colons only work in the delimiter row. A colon in a data cell is plain text.
  • The HTML output differs by parser. GitHub's cmark-gfm writes <td align="right">; markdown-it (VS Code, many static sites), Goldmark (Hugo) and Pandoc write style="text-align: right". A site stylesheet that sets text-align on cells overrides the align attribute but not an inline style, which is why the same table can align on one site and not another.
The shortest valid delimiters: one hyphen each
Markdown
| Item | Qty | Status |
|:-|-:|:-:|
| Apples | 12 | ✅ |
| Pears | 140 | ⏳ |
Preview
ItemQtyStatus
Apples12✅
Pears140⏳

Valid GFM. Run it through the table formatter to pad the source so the pipes line up.

Open in editor : The shortest valid delimiters: one hyphen each

Worked example: a pricing table

A typical real table mixes all three: text on the left for scanning, short status values centered, and money on the right so the decimal points line up.

Left text, centered dates and icons, right-aligned prices
Markdown
| Feature            | Released   | Pro | Monthly cost |
| :----------------- | :--------: | :-: | -----------: |
| Developer API      | 2025-01-15 | ✅  |       $19.00 |
| Enterprise SSO     | 2025-03-01 | ✅  |      $499.00 |
| Dedicated database | 2025-06-30 | ⏳  |    $1,250.50 |
Preview
FeatureReleasedProMonthly cost
Developer API2025-01-15✅$19.00
Enterprise SSO2025-03-01✅$499.00
Dedicated database2025-06-30⏳$1,250.50

Markdown has no decimal-point alignment. Right alignment lines up decimals only when every number has the same number of decimal places, so write $19.00, not $19, next to $1,250.50. Put the unit in the header (“Monthly cost (USD)”) rather than in each cell when you can; it keeps the column narrow and easier to compare.

What happens without colons?

A --- cell means “no alignment”: the parser writes plain <th> and <td> elements and leaves the rest to CSS. Data cells then inherit the page's text direction, so they show left-aligned in English. Header cells are different: the browsers' default stylesheet centers <th> text, so on a site whose CSS doesn't override it you get centered headers over left-aligned data. If you want the header to sit flush with its column everywhere, say so explicitly with :---.

How do I center only the header?

Pipe syntax can't do this: the colons align the header and the data together. Three workarounds, from most to least portable:

  1. HTML inside the header cells (GitHub). Wrap each header in <div align="center"> and keep :--- for the column. GitHub keeps the align attribute.
  2. CSS on sites you control. th { text-align: center; } in MkDocs, Docusaurus, Hugo or Jekyll. It won't override an explicit inline style alignment, so leave those columns as ---.
  3. A full HTML table with <th align="center"> and plain <td> cells.
Centered headers over left-aligned data (GitHub)
Markdown
| <div align="center">Name</div> | <div align="center">Notes</div> |
| :--- | :--- |
| Ada | Wrote the first program |
| Grace | Built the first compiler |
Preview
NameNotes
AdaWrote the first program
GraceBuilt the first compiler

Preview shows the GitHub result. Renderers that escape HTML show the <div> tags as text.

How do I center the whole table on the page?

Alignment colons move text inside cells; they never move the table. Centering the table itself is a layout job, so the method depends on where the Markdown is rendered.

Centering the whole table, by platform
PlatformMethod
GitHub README, issues, wikisWrap the table in <div align="center"> with blank lines inside the div
MkDocs, Docusaurus, Hugo, JekyllCustom CSS: width: fit-content; margin-inline: auto on table
ObsidianA CSS snippet (Settings → Appearance → CSS snippets)
VS Code previewA stylesheet listed in the markdown.styles setting
JupyterAlready centered by default (see below)
Pandoc to PDFLaTeX longtable output is centered by default
Center a table on GitHub
Markdown
<div align="center">

| Plan | Price |
| :--- | ----: |
| Free | $0 |
| Pro  | $8 |

</div>

The blank lines matter: without them the table stays inside the HTML block and isn't parsed. Columns without colons may inherit the centering, so set :--- where you want left.

Center tables on a static siteCSS
/* Docusaurus: src/css/custom.css · MkDocs: a file listed in extra_css
   Hugo / Jekyll: your theme's stylesheet */
article table {
  width: fit-content;   /* shrink the table to its content (also works for display:block) */
  max-width: 100%;      /* wide tables still scroll instead of overflowing */
  margin-inline: auto;  /* center it */
}

width: fit-content is there because several site themes (and GitHub) style tables as display: block, which makes a plain margin: auto do nothing. If the rule still has no effect, inspect the table: some themes (MkDocs Material, for one) make it inline-block inside a wrapper, and then the wrapper needs text-align: center instead. For a table that spans the full width instead, see column width.

Can I top-align cells vertically?

No. GFM and the other pipe-table flavors have no vertical-alignment syntax. Browsers center cell content vertically by default, which you notice as soon as one cell holds several lines via <br> line breaks and its neighbours float in the middle. The fixes:

Top-aligned row on GitHubHTML
<table>
  <tr>
    <th>Step</th>
    <th>Details</th>
  </tr>
  <tr valign="top">
    <td>Install</td>
    <td>Run npm install<br>then npm run build<br>then npm test</td>
  </tr>
</table>
CSS
/* Sites where you control the stylesheet */
td, th {
  vertical-align: top;
}

GitHub keeps valign but strips style, so the attribute is the only option there.

Jupyter: tables centered or right-aligned

Jupyter adds its own table CSS on top of the Markdown output, which causes two separate surprises:

  • The table is centered on the page. Both the classic Notebook and JupyterLab give tables margin-left: auto; margin-right: auto.
  • Cell text is right-aligned. The classic Notebook (and some older JupyterLab releases) right-align all table cells, a style meant for DataFrame output. Explicit colons usually fix it: write :--- for every text column instead of ---.

To move the table itself to the left, override the margin in a custom stylesheet:

custom.cssCSS
/* ~/.jupyter/custom/custom.css
   Classic Notebook loads it automatically; JupyterLab 4.1+ and
   Notebook 7.1+ need custom CSS enabled (LabApp.custom_css = True). */
.jp-RenderedMarkdown table,
.rendered_html table {
  margin-left: 0;   /* stop centering tables on the page */
}

In the classic Notebook, a <style> block with the same rule inside a Markdown cell also works for a trusted notebook. Exact selectors vary between Jupyter versions, so check the rendered HTML with your browser's inspector if a rule doesn't apply.

Alignment support by platform

Column alignment, table centering and vertical alignment by platform
PlatformColon alignmentCenter the tableTop-align cells
GitHub (GFM)Writes an align attribute on each cell. Keeps align and valign on HTML, strips style.YesPartly: <div align="center"> wrapperPartly: HTML valign="top"
GitLab (GLFM)Same colon syntax as GitHub.YesNot applicableNot applicable
ObsidianReading view and Live Preview both follow the colons.YesPartly: CSS snippetPartly: CSS snippet
VS Code previewmarkdown-it writes style="text-align:…" on cells.YesPartly: markdown.styles CSSPartly: markdown.styles CSS
JupyterTables are centered on the page; older frontends right-align cells without colons.Partly: Use explicit colonsYes: Centered by defaultPartly: custom.css
Pandoc / QuartoColons in pipe and grid tables; position-based alignment in simple and multiline tables.YesPartly: PDF output centers; HTML via CSSPartly: CSS
MkDocs, Docusaurus, Hugo, JekyllAll follow the colons (kramdown in Jekyll included).YesPartly: Custom CSSPartly: Custom CSS
RedditMarkdown editor only.YesNoNo
Slack, DiscordNo Markdown tables in messages. Slack Block Kit tables set align per column.No: No tablesNot applicableNot applicable

✅ supported · ⚠️ partly or with a workaround · ❌ not supported · Last verified October 2026

“—” means not covered here. “Custom CSS” only applies where you control the site's stylesheet.

Common mistakes (broken vs. fixed)

A space between the colon and the hyphens

Broken: --- : is not a delimiter cell
Markdown
| Item | Price |
| :--- | --- : |
| Tea  | 3.50  |
Preview

| Item | Price | | :--- | --- : | | Tea | 3.50 |

Renders as a plain paragraph, not a table.

Fixed: colon touching the hyphens
Markdown
| Item | Price |
| :--- | ----: |
| Tea  | 3.50  |
Preview
ItemPrice
Tea3.50

Fewer delimiter cells than header cells

Adding a column to the header and forgetting its delimiter cell is the most common way to break an aligned table: GFM requires the header and delimiter rows to have the same number of cells.

Broken: three headers, two delimiter cells
Markdown
| Item | Qty | Price |
| :--- | --: |
| Tea  | 2   | 3.50  |
Preview

| Item | Qty | Price | | :--- | --: | | Tea | 2 | 3.50 |

Renders as a plain paragraph, not a table.

Fixed: one delimiter cell per column
Markdown
| Item | Qty | Price |
| :--- | --: | ----: |
| Tea  | 2   | 3.50  |
Preview
ItemQtyPrice
Tea23.50

Colons in the data instead of the delimiter row

Broken: the colons show up as text
Markdown
| Item  | Price  |
| ----- | ------ |
| :Tea  | 3.50:  |
Preview
ItemPrice
:Tea3.50:

Alignment is never read from data rows.

Open in editor : Broken: the colons show up as text
Fixed: colons moved to the delimiter row
Markdown
| Item | Price |
| :--- | ----: |
| Tea  | 3.50  |
Preview
ItemPrice
Tea3.50

The table validator flags mismatched and malformed delimiter rows with the line number.

When to switch to HTML

Stay with colons for column alignment; it is portable and readable. Switch to an HTML table when you need:

  • different alignment for one cell or one row (<td align="…">)
  • headers aligned differently from their data, outside GitHub
  • vertical alignment (valign) on GitHub, or merged cells (see merged cells)

Remember that GitHub drops style attributes, so use the old align and valign attributes there. For everything else about the pipe syntax, see the Markdown table syntax guide.

Frequently asked questions

How do I center text in a Markdown table?

Put a colon on both ends of that column's delimiter cell: | :---: |. The header and every cell in the column are centered. Use ---: for right alignment and :--- for left.

Can I align a single cell differently from its column?

No. Pipe-table alignment is set per column in the delimiter row. For one cell, write the table in HTML and use <td align="right">, which GitHub keeps (it strips style attributes).

How do I center only the header row of a Markdown table?

Not with colons, because they apply to the whole column. On GitHub, wrap each header in <div align="center">…</div> and keep :--- for the data. On sites you style yourself, add th { text-align: center; }.

How do I center a Markdown table on the page?

On GitHub, wrap the table in <div align="center"> with a blank line after the opening tag and before </div>. On MkDocs, Docusaurus, Hugo or Jekyll, add CSS: table { width: fit-content; margin-inline: auto; }.

Can Markdown tables be top-aligned (vertical alignment)?

No. Pipe tables have no vertical-alignment syntax, and browsers center cell content vertically by default. Use an HTML table with valign="top" on the row (GitHub keeps it), or CSS td { vertical-align: top; } on sites you control.

Why is my Markdown table right-aligned in Jupyter?

Jupyter's stylesheet right-aligns table cells in the classic Notebook and some older JupyterLab versions. Add explicit colons (:---) to the delimiter row. Tables are also centered on the page by default; override that with margin-left: 0 in a custom CSS file.

Does the number of hyphens change the alignment?

No. Only the colons matter. GFM accepts one hyphen per cell (:-:), GitHub Docs suggest three, and extra hyphens just pad the source so the columns line up.