251

Is it possible to create a table without a header in Markdown?

The HTML would look like this:

<table>
<tr>
    <td>Key 1</td>
    <td>Value 1</td>
</tr>
<tr>
    <td>Key 2</td>
    <td>Value 2</td>
</tr>
</table>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
adius
  • 13,685
  • 7
  • 45
  • 46

12 Answers12

155

Most Markdown parsers don't support tables without headers. That means the separation line for headers is mandatory.

Parsers that do not support tables without headers

Parsers that do support tables without headers.

CSS solution

If you're able to change the CSS of the HTML output you can however leverage the :empty pseudo class to hide an empty header and make it look like there is no header at all.

DRCB
  • 2,111
  • 13
  • 21
adius
  • 13,685
  • 7
  • 45
  • 46
  • 7
    More on CSS solution: http://stackoverflow.com/questions/12023771/hide-empty-cells-in-table – Vadzim Aug 26 '16 at 20:24
  • `:empty` doesn't help because if you only hide the `` it doesn't look right; you have to hide the whole `` or even the entire ``. – Ron Inbar Nov 18 '20 at 09:18
149

If you don't mind wasting a line by leaving it empty, consider the following hack (it is a hack, and use this only if you don't like adding any additional plugins).

|   |   |
|---|---|
|__Bold Key__| Value1 |
| Normal Key | Value2 |
Bold Key Value1
Normal Key Value2

To view how the above one could look, copy the above and visit https://stackedit.io/app

It worked with GitLab/GitHub's Markdown implementations.

philipxy
  • 14,867
  • 6
  • 39
  • 83
Thamme Gowda
  • 11,249
  • 5
  • 50
  • 57
39

Universal Solution

Many of the suggestions unfortunately do not work for all Markdown viewers/editors, for instance, the popular Markdown Viewer Chrome extension, but they do work with iA Writer.

What does seem to work across both of these popular programs (and might work for your particular application) is to use HTML comment blocks ('<!-- -->'):

| <!-- -->    | <!-- -->    |
|-------------|-------------|
| Foo         | Bar         |
Foo Bar

Like some of the earlier suggestions stated, this does add an empty header row in your Markdown viewer/editor. In iA Writer, it's aesthetically small enough that it doesn't get in my way too much.

philipxy
  • 14,867
  • 6
  • 39
  • 83
Tony Barganski
  • 1,873
  • 20
  • 17
  • This completely defats the point of using Markdown, as when viewed as text-only, the comments will be stripped and the columns won't even align anymore. – hackel May 03 '20 at 05:50
  • 3
    I think @hackel misunderstood. This does not align the columns using fixed widths. Rather, it gives a nice workaround to have valid but empty column headers. It was a great workaround in my situation. The table still rendered as intended/expected; it simply had no header row. – mdahlman May 11 '20 at 20:32
  • 2
    Nice, yet [this really isn't a **universal** solution](https://babelmark.github.io/?text=%7C+%3C!--+--%3E++++%7C+%3C!--+--%3E++++%7C%0A%7C-------------%7C-------------%7C%0A%7C+Foo+++++++++%7C+Bar+++++++++%7C) – Ulysse BN Apr 19 '21 at 07:41
  • 1
    This will create an empty table header and an empty row. – 41 72 6c Jun 30 '21 at 12:49
  • @Tony Isn't it better to just leave the header cells empty? – user90726 Aug 01 '21 at 07:57
  • @UlysseBN Could you point me which Markdown implementations from the link you provided fail to parse this syntax? – user90726 Aug 01 '21 at 07:59
  • @jsv there 20 failing implementations nowadays, but this may change, just click the link! – Ulysse BN Aug 01 '21 at 08:37
  • Doesn't work for me (in github issues) – theking2 Jan 25 '22 at 22:28
  • @theking2 That's odd. I just tried it on github issues and works for me. – Tony Barganski Feb 04 '22 at 13:26
  • 1
    @TonyBarganski I must have missed a typo. You are right it does work. And actually without the `` in the header line. Leaving empty spaces – theking2 Feb 10 '22 at 15:52
  • An __Universal Solution__ that doesn't work with PDF... – Marc Le Bihan May 03 '22 at 05:36
  • @MarcLeBihan I haven't had any issues with PDFs. What are you using to generate your PDF? – Tony Barganski May 04 '22 at 07:12
21

I got this working with Bitbucket's Markdown by using a empty link:

[]()  | 
------|------
Row 1 | row 2
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Stuart Campbell
  • 1,141
  • 11
  • 13
  • 2
    Will also prompt an empty header line. At least its only half the height as an normal line. Worked for me as Hack in github too – Londane Jul 12 '16 at 20:49
  • This hack worked for me when writing documentation in Insomnia. Still creates a header line, but it's a lot shorter than if I put text in there. Thanks! – jkmartindale Apr 02 '18 at 20:25
  • Brilliant! I still see a little vertical space with Github Markdown, but it's better than before. – Keith Bennett Oct 01 '19 at 12:14
16

At least for the GitHub Flavoured Markdown, you can give the illusion by making all the non‑header row entries bold with the regular __ or ** formatting:

|Regular | text | in header | turns bold |
|-|-|-|-|
| __So__ | __bold__ | __all__ | __table entries__ |
| __and__ | __it looks__ | __like a__ | __"headerless table"__ |
Regular text in header turns bold
So bold all table entries
and it looks like a "headerless table"
philipxy
  • 14,867
  • 6
  • 39
  • 83
TT--
  • 2,956
  • 1
  • 27
  • 46
  • I was looking for something that'd work in GFM and this hack is a creative one! – Mrchief Jun 29 '19 at 15:03
  • There's a problem when rendered tables have a different color for header row (e.g. StackExchange). – Ruslan Apr 17 '21 at 12:19
  • By default, the header texts are center aligned, you may want to align them to the left if you don't want the header to standout. In your second line, change it to `|:-|:-|:-|:-|` – NearHuscarl Apr 28 '22 at 11:11
9

Omitting the header above the divider produces a headerless table in at least Perl Text::MultiMarkdown and in FletcherPenney MultiMarkdown

|-------------|--------|
|**Name:**    |John Doe|
|**Position:**|CEO     |

See PHP Markdown feature request


Empty headers in PHP Parsedown produce tables with empty headers that are usually invisible (depending on your CSS) and so look like headerless tables.

|     |     |
|-----|-----|
|Foo  |37   |
|Bar  |101  |
RedGrittyBrick
  • 3,827
  • 1
  • 30
  • 51
  • About the use of Parsedown, actually the header is still here, just check the HTML. If you have a CSS padding on cells you will see the header cells. But I guess that `table th:empty { padding: 0; }` would fix that. – AymDev Sep 15 '18 at 15:09
  • All of these is now included in [adius' answer](https://stackoverflow.com/a/17543474/7009806). – Olivier Mar 20 '23 at 07:51
8

You may be able to hide a heading if you can add the following CSS:

<style>
    th {
        display: none;
    }
</style>

This is a bit heavy-handed and doesn’t distinguish between tables, but it may do for a simple task.

Update

HTML output varies between Markdown editors, but if the table includes a thead element, you can target the empty header cells more specifically with:

thead th:empty {
    border: thin solid red !important;
    display: none;
}

This works if your header row contains no visible content. Spaces between the bars are OK.

Manngo
  • 14,066
  • 10
  • 88
  • 110
  • The only CSS trick that works for me for some reason (I'm using VNote with the Markdown-it renderer). None of the solutions given here: https://stackoverflow.com/questions/12023771/hide-empty-cells-in-table worked. – what the Jul 09 '20 at 13:09
6

The following works well for me in GitHub. The first row is no longer bolded as it is not a header:

<table align="center">
    <tr>
        <td align="center"><img src="docs/img1.png?raw=true" alt="some text"></td>
        <td align="center">Some other text</td>
        <td align="center">More text</td>
    </tr>
    <tr>
        <td align="center"><img src="docs/img2.png?raw=true" alt="some text"></td>
        <td align="center">Some other text 2</td>
        <td align="center">More text 2</td>
    </tr>
</table>

Check a sample HTML table without a header here.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Daniel
  • 21,933
  • 14
  • 72
  • 101
  • 11
    This is just what the questioner said they didn't want. – Neil Mayhew Dec 11 '18 at 22:51
  • HTML tables don't seem to work in Bitbucket (https://community.atlassian.com/t5/Bitbucket-questions/html-table-in-readme-does-not-render-as-table/qaq-p/766135) - it displays the HTML itself rather than rendering a table. – jsaven Jul 02 '19 at 08:16
4
$ cat foo.md
Key 1 | Value 1
Key 2 | Value 2
$ kramdown foo.md
<table>
  <tbody>
    <tr>
      <td>Key 1</td>
      <td>Value 1</td>
    </tr>
    <tr>
      <td>Key 2</td>
      <td>Value 2</td>
    </tr>
  </tbody>
</table>
Zombo
  • 1
  • 62
  • 391
  • 407
  • 1
    This seems not to work with https://github.com/chjj/marked . Is there a reference, in which I can look up if this is even the expected behavior? – adius Jul 09 '13 at 07:50
2

I use <span> in the first column header:

 <span> |
---     |    ---
Value   |  Value
Value   |  Value

It creates an empty header with border, but with 1/2 the size.

Value
Value
philipxy
  • 14,867
  • 6
  • 39
  • 83
1

what works in GitHub issue editor is

&nbsp; |&nbsp;
------ | ---
Foo    | Bar

But it does show an empty header

   
Foo Bar
philipxy
  • 14,867
  • 6
  • 39
  • 83
theking2
  • 2,174
  • 1
  • 27
  • 36
  • 1
    As someone with a quasi-Markdown parser that does tables I'm wondering if I should "special case" the first row being non-breaking space cells - and just suppress the header row. My target (PowerPoint slides) would happily support a headerless table. Or would this be considered a deviation too far? (I already have a section in the manual for such deviations - so could add this as "some other parsers might not...") – Martin Packer Dec 24 '22 at 12:10
1
<style>
    .headerless th {
        display: none;
    }
</style>

<div class="headerless">

| | |
|---|---|
|Some |table |
| WITHOUT | header |
</div>

|This|is|
|---|---|
|Some |table |
| WITH |header |
Aleksandr
  • 11
  • 2
  • Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Nov 15 '22 at 00:34