11

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>
| improve this question | | | | |
  • 2
    Your answer is here: webapps.stackexchange.com/questions/6700/… first answer links to a website that will do this for you. – user1228 Jul 1 '11 at 13:42
  • Not a duplicate of that question. This question is about tables -- that question is about ASCII tables. – Andy Thomas Apr 29 '16 at 21:46
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.

| improve this answer | | | | |
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] │ 
  └───────────┴───────────┴───────────┴───────────┘ 
| improve this answer | | | | |
  • 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.

| improve this answer | | | | |
  • 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 .