11

This question already has an answer here:

I want to use a table in my answer.
e.g

|-------------|----------------|
| ShortCut | Description |
|-------------|----------------|

I have posted an answer here, which requires this kind of formatting.

Is it possible to have such formatting in stackoverflow Questions & answers ?

  • If yes, How ?
  • If no, why ?

Edit : I tried to use following code directly in editor of SO. But it didn't work for me.

<table>
<tr>
<td>hello</td>
<td>hello2</td>
</tr>
<tr>
<td>hello3</td>
<td>hello4</td>
</tr>
</table>

marked as duplicate by Shadow discussion Sep 9 '15 at 13:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

Standard Markdown should have allowed in-lined HTML table. However, seems it's not supported by SE's implementation of Markdown.

There are currently few Markdown implementation, which do support tables syntax originally created for PHP Markdown Extra.

Tables in above syntax have source like this:

| Left align | Right align | Center align |
|:-----------|------------:|:------------:|
| This       |        This |     This     |
| column     |      column |    column    |
| will       |        will |     will     |
| be         |          be |      be      |
| left       |       right |    center    |
| aligned    |     aligned |   aligned    |

And are rendered as HTML table, which looks like this:

rendered table

Example table is from this Python implementation.

4

You can use Unicode characters. For example:

                   [My DataTabel]                                     
  ┌───────────┬───────────┼───────────┬───────────┐
  │  Field#1  │  Field#2  │    ∙∙∙    │  Field#n  │
  ├───────────┼───────────┼───────────┼───────────┤
  │ Data[1-1] │ Data[1-2] │    ∙∙∙    │ Data[1-n] │
  ├───────────┼───────────┼───────────┼───────────┤
  │ Data[2-1] │ Data[2-2] │    ∙∙∙    │ Data[2-n] │
  ├───────────┼───────────┼───────────┼───────────┤
  │    ∙∙∙    │    ∙∙∙    │    ∙∙∙    │    ∙∙∙    │
  ├───────────┼───────────┼───────────┼───────────┤ 
  │ Data[m-1] │ Data[m-2] │    ∙∙∙    │ Data[m-n] │ 
  └───────────┴───────────┴───────────┴───────────┘ 
  • Those are box-drawing characters, not 7-bit ASCII characters. – Guildenstern Nov 5 '17 at 0:49
  • 1
    updated to unicode – Mimi Nov 5 '17 at 6:12
3

I fail to see why a table is needed for that answer.

But if you want to create a table, your best bet is to use the one you've posted in code tags:

|-------------|----------------|
| ShortCut    | Description    |
|-------------|----------------|

This could also be extended with Unicode.

It does not support extended formatting, though.

  • does <code> tag supports <kbd> tag within it ? – Sagar R. Kothari Jul 1 '11 at 11:01
  • @sugar: No, I don't think so. – Time Traveling Bobby Jul 1 '11 at 11:01
  • I posted the link to my answer just because I want to give some Idea of a case where Table is very necessary to demonstrate neat & sharp. – Sagar R. Kothari Jul 1 '11 at 11:04
  • Note that the mobile theme uses wrapping, not scrolling. Makes ASCII tables look very bad. – Arjan Aug 4 '12 at 12:29

Not the answer you're looking for? Browse other questions tagged .