How to Set Column Width in a Markdown Table
By MarkdownTables.com editorial teamUpdated
On this page
Ways to control column width
| Technique | Syntax | Works on | Effect |
|---|---|---|---|
| Non-breaking spaces | Header | GitHub, GitLab, Obsidian, most renderers | Minimum width |
| Spacer image | <img width="240" height="1" src="…"> | Renderers that allow <img>, including GitHub | Minimum width in pixels |
HTML width attribute | <th width="220"> | HTML tables; a hint on GitHub | Preferred width |
| CSS | table-layout: fixed + th { width: 30% } | Your own site, MkDocs, Docusaurus, Obsidian snippets | Exact widths, full width |
| Dash counts | |-----|---------------| | Pandoc, when a row exceeds 72 characters | Relative widths |
tbl-colwidths | : Caption {tbl-colwidths="[25,75]"} | Quarto | Percent widths |
padding| Option | Default | Description |
| :--- | :---: | :--- |
| `timeout` | 30 | Seconds before the request is aborted |
| `retries` | 3 | Attempts after the first failure || Option | Default | Description |
|---|---|---|
timeout | 30 | Seconds before the request is aborted |
retries | 3 | Attempts after the first failure |
Works anywhere HTML entities are decoded. The preview shows the minimum width the padding forces.
Open in editor : Widen the first column with paddingWhy columns size themselves
A pipe table becomes a plain HTML <table> with no width information. Browsers then use automatic table layout: each column gets the width its content needs, and long text wraps once the table hits the width of the page. Spaces you add in the source to line up the pipes are collapsed by the browser, so they never affect the rendered width; they only make the source readable (which is what the table formatter does).
Every workaround therefore does one of two things: it puts wider content in the column (non-breaking spaces, a spacer image), or it adds CSS that overrides automatic layout.
How do I widen a column on GitHub?
GitHub strips style attributes and doesn't let you add CSS, so content is the only lever. Its stylesheet makes tables display: block; width: max-content; max-width: 100%: a table is exactly as wide as its content and scrolls horizontally when it is wider than the page.
Pad the header with
Non-breaking spaces are real characters that don't collapse or wrap, so ten of them add roughly ten characters of width. Put them in the header cell only. This is the simplest fix and works on GitHub, GitLab, Obsidian and VS Code.
Add a spacer image
For a width in pixels, put an image with a width attribute in the header. Point it at a transparent 1×1 image committed to your repository and give it height="1" so it stays invisible.
| Name<br><img width="240" height="1" src="docs/spacer.png" alt=""> | Notes |
| :--- | :--- |
| `timeout` | Seconds before the request is aborted || Name | Notes |
|---|---|
timeout | Seconds before the request is aborted |
GitHub keeps width and height on <img>. Replace docs/spacer.png with a transparent image in your repo.
HTML tables with width attributes
In an HTML table you can set width on <th> or <td> in pixels or percent. Renderers that keep the attribute treat it as the column's preferred width. On GitHub, the attribute is kept but the content-sized table stylesheet makes the result inconsistent, so check the rendered page.
<table>
<tr>
<th width="100">Method</th>
<th width="220">Endpoint</th>
<th width="380">Description</th>
</tr>
<tr>
<td><code>GET</code></td>
<td><code>/api/v1/users</code></td>
<td>Lists active users with their roles</td>
</tr>
<tr>
<td><code>POST</code></td>
<td><code>/api/v1/users</code></td>
<td>Creates a user and sends an activation email</td>
</tr>
</table>Don't put <th width="…"> inside a pipe-table header cell: that nests a header cell inside another one. Convert the whole table with Markdown table to HTML first.
Setting widths with CSS on your own site
Where you control the stylesheet, CSS gives real control. With the default table-layout: auto, widths are suggestions the content can override. With table-layout: fixed and a table width, the widths you set are applied exactly and the content wraps to fit.
/* Fixed layout: the widths you set win over the content */
article table {
table-layout: fixed;
width: 100%;
}
article table th:nth-child(1) { width: 20%; }
article table th:nth-child(2) { width: 15%; }
/* the remaining column gets the rest */
article table td {
overflow-wrap: anywhere; /* long URLs and identifiers wrap instead of overflowing */
}/* Auto layout, but never narrower than this */
article table th:first-child {
min-width: 12rem;
}Pipe tables don't take classes or ids in GFM, so CSS targets columns by position with :nth-child(). If only some tables need it, wrap them in a <div class="…"> (with blank lines around the table so it is still parsed as Markdown) and scope the selector to that class.
How do I make a table full width?
A table that stops halfway across the page is usually the theme, not your Markdown. Many themes deliberately size tables to their content and make them scroll horizontally when they are too wide, which works well on phones. To stretch them, override the table's display and width:
- GitHub: not possible;
width="100%"on an HTML table is overridden by the stylesheet. A long header row or a wide spacer image is the only way to make a table wider. - Your own site:
table { display: table; width: 100%; }. Keep anoverflow-x: autowrapper for tables that may be wider than a phone screen. - Obsidian: also turn off Settings → Editor → “Readable line length”, which caps the width of the whole note.
MkDocs, Docusaurus and Obsidian recipes
MkDocs (Material theme)
Material wraps each table in a scroll container and sizes it to its content. These rules stretch tables to the full content width and set the first column:
/* docs/stylesheets/extra.css
mkdocs.yml:
extra_css:
- stylesheets/extra.css */
/* Material for MkDocs: stretch tables to the content width */
.md-typeset__table {
min-width: 100%;
}
.md-typeset table:not([class]) {
display: table;
}
/* First column 30% wide */
.md-typeset table:not([class]) th:first-child {
width: 30%;
}Docusaurus
/* src/css/custom.css */
.markdown table {
display: table; /* Infima renders tables as display:block */
width: 100%;
}
.markdown table th:first-child {
width: 30%;
}display: table removes Infima's built-in horizontal scrolling, so wide tables will overflow on small screens. Scope the rule to a wrapper class if only some tables should stretch.
Obsidian
/* .obsidian/snippets/tables.css
Enable it in Settings → Appearance → CSS snippets */
.markdown-rendered table {
width: 100%;
}
.markdown-rendered table th:first-child {
width: 30%;
}.markdown-rendered targets Reading view. Live Preview uses different elements; open the developer tools (Ctrl+Shift+I, or Cmd+Option+I on macOS) to find the selector for your Obsidian version and theme.
Pandoc and Quarto: relative widths
Pandoc is the only common Markdown processor where the delimiter row affects width. According to the Pandoc manual, if any line of a pipe table is longer than the column limit (--columns, 72 by default), the table spans the full text width and each column's share is proportional to its number of dashes. Shorter tables keep their natural widths. Here the separator has 7 and 79 dashes, so the first column gets about 8% of the width.
| Term | Definition |
|-------|-------------------------------------------------------------------------------|
| Width | Relative widths come from the dash counts once a row is longer than 72 chars || Term | Definition |
|---|---|
| Width | Relative widths come from the dash counts once a row is longer than 72 chars |
Preview shows the Pandoc result. GitHub ignores the dash counts and sizes columns to content.
Open in editor : Pandoc: dash counts become relative widthsQuarto, which uses Pandoc, also accepts explicit percentages in the table caption:
| Term | Definition |
|-------|----------------------------------|
| Width | Set explicitly with tbl-colwidths |
: Glossary {tbl-colwidths="[25,75]"}More in the Pandoc tables guide.
Column width support by platform
| Platform | Width in Markdown | Full-width tables | Per-column widths |
|---|---|---|---|
GitHub (GFM)Tables are width: max-content and scroll when wider than the page. style is stripped. | No | No: Sized to content | Partly: or spacer image |
| GitLab (GLFM)No width syntax; same padding tricks apply. | No | Not applicable | Partly: padding |
| ObsidianTurn off “Readable line length” for wide tables. | No | Yes: CSS snippet | Yes: CSS snippet |
VS Code previewAdd a stylesheet through the markdown.styles setting. | No | Yes: Custom CSS | Yes: Custom CSS |
Pandoc / QuartoDash counts set relative widths; Quarto adds tbl-colwidths. | Yes: Dashes, tbl-colwidths | Yes: When a row exceeds --columns | Yes |
| MkDocs (Material)Tables shrink to content by default. | No | Yes: extra_css | Yes: extra_css |
DocusaurusInfima styles tables as display: block. | No | Yes: custom.css | Yes: custom.css |
Hugo, JekyllPlain <table> output; the theme CSS decides. | No | Yes: Theme CSS | Yes: Theme CSS |
✅ supported · ⚠️ partly or with a workaround · ❌ not supported · Last verified October 2026
“—” means not covered here. CSS options only apply where you can add a stylesheet.
Common mistakes (broken vs. fixed)
Padding the source with spaces
| Name | Value |
| --------------------------------- | ----- |
| retries | 3 || Name | Value |
|---|---|
| retries | 3 |
The source looks wide, but the rendered column is only as wide as “retries”. Use in the header instead.
Putting in the delimiter row
| Name | Value |
| --- | ----- |
| retries | 3 || Name | Value | | --- | ----- | | retries | 3 |
Renders as a plain paragraph, not a table.
A bare URL stretching the column
| Package | Source |
| :--- | :--- |
| table-engine | https://github.com/example-org/markdown-table-engine/blob/main/packages/core/README.md || Package | Source |
|---|---|
| table-engine | https://github.com/example-org/markdown-table-engine/blob/main/packages/core/README.md |
| Package | Source |
| :--- | :--- |
| table-engine | [README](https://github.com/example-org/markdown-table-engine/blob/main/packages/core/README.md) || Package | Source |
|---|---|
| table-engine | README |
Using style attributes on GitHub
<td style="width: 200px"> works in some renderers, but GitHub removes the style attribute entirely, so the width silently disappears. Use the attribute form or a spacer image there.
When to switch to HTML or restructure
Width fights are often a sign the table has the wrong shape. Before reaching for HTML, consider:
- Too many columns: transpose the table so the columns become rows, or split it in two.
- One long text column: move the prose out of the table, or break it with <br> line breaks.
- Cramped headers: shorten them, or put units on a second line.
Switch to an HTML table when you need fixed widths on a renderer that allows attributes but no CSS, or when the table also needs merged cells. To place the table rather than size its columns, see centering a table, and for the rest of the syntax the Markdown table syntax guide.
Frequently asked questions
How do I specify column width in a Markdown table?
You can't with pipe syntax; columns size to their content. Pad the header with or add an <img width="200"> spacer to widen a column, write an HTML table with width attributes, or set widths with CSS where you control the stylesheet.
Why is my Markdown table not full width?
Most renderers size tables to their content. GitHub, Docusaurus and MkDocs Material style tables so they only grow as wide as the text. On your own site, add CSS such as table { display: table; width: 100%; }; on GitHub it isn't possible.
Does the number of hyphens in the delimiter row change the width?
Not in GFM or on GitHub; hyphens only matter for alignment colons. Pandoc is the exception: when a row is longer than 72 characters, the dash counts set the relative column widths.
Does <th width="300"> work on GitHub?
Only as a hint. GitHub keeps the width attribute in HTML tables, but its stylesheet sizes tables to their content, so the result is inconsistent. padding or a spacer image in the header is more predictable.
How do I set column widths in MkDocs or Docusaurus?
With CSS. In MkDocs, add a stylesheet under extra_css and target .md-typeset table:not([class]) th:nth-child(1). In Docusaurus, put the rule in src/css/custom.css and target .markdown table. Add table-layout: fixed for exact widths.
How do I stop a long URL from stretching a column?
Use link text instead of the bare URL: [README](https://…). A long string with no spaces cannot wrap, so it forces the column to its full length. On your own site, overflow-wrap: anywhere on cells also fixes it.