5

HTML allows extending a table's header row across multiple columns using colspan:

<table>
  <tr><th colspan=2>Logical Operators</th></tr>
  <tr><td>&&</td><td>Logical and</td></tr>
  <tr><td>||</td><td>Logical or</td></tr>
  <tr><td>!</td><td>Logical not</td></tr>
  <tr><td>? :</td><td>Logical ternary</td></tr>
</table>

On GitHub, when this HTML is rendered in a readme.md file it looks like this:

enter image description here

...but using markdown syntax to create a table, I can't span the table's header row across columns, e.g. I can only split up the header text:

| Logical | Operators |
|:---:| --- |
| `&&` | Logical and |
| `\|\|` | Logical or |
| `!` | Logical not |
| `? :` | Logical ternary |

...and rendering the GFM table on GitHub looks like:

enter image description here

I tried emulating this solution for using colspan in the table's data rows, but I could not get it to work with the header row. Is there a way to span the GFM table's header row across more than one column with GitHub flavored Markdown?

I've posted the question to the folks at the GH MD repo.

MmmHmm
  • 3,435
  • 2
  • 27
  • 49

1 Answers1

-1

I did it this way in order to generate a table with 5 columns with headers spanning respectively over 3 and 2 columns:

<table>
<tr>
<td colspan=3>a  <td colspan=2>b
<tr>
<td colspan=1>col1 <td colspan=1>col2 <td colspan=1>col3<td colspan=1>col4 <td colspan=1>col5
</table>

My two cents.

damianooldoni
  • 475
  • 5
  • 6