462

I have the following cells in a markdown table:

something something that's rather long and goes on for a very long time something else

I'd like to be able to insert a break in the middle line, so the middle column isn't so wide. How can I do that in Markdown? Do I need to use HTML tables instead?

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • When using `
    ` be careful that you don't leave any space in the front(indentation). I've had the same problem but when I removed the tab space it worked.
    – Varun Kumar Sep 23 '19 at 10:18

5 Answers5

624

Use an HTML line break (<br />) to force a line break within a table cell:

| something | something that's rather long and <br />goes on for a very long time | something else |
|-----------|---------------------------------------------------------------|----------------|

Rendered:

something something that's rather long and
goes on for a very long time
something else
mikemaccana
  • 110,530
  • 99
  • 389
  • 494
jwal
  • 7,290
  • 1
  • 21
  • 11
  • 15
    The
    syntax works only when you convert to HTML - at least in `pandoc`.
    – halloleo Jul 05 '15 at 04:11
  • 10
    The `
    ` syntax also works on GitLab, which uses [Redcarpet Ruby library](https://github.com/vmg/redcarpet) for Markdown processing ([reference](https://docs.gitlab.com/ee/user/markdown.html))
    – Dinei Aug 18 '17 at 15:45
  • 11
    To whomever edited this answer on 14 November 2020: You have introduced a syntax error by adding a backslash to the tag. Backslashes don't close tags in HTML. I can't edit the answer myself because of the minimum character limit. – Psychonaut Nov 26 '20 at 10:44
  • This works for Obsidian as well – Brent George Nov 03 '22 at 20:09
60

When you're exporting to HTML, using <br> works. However, if you're using pandoc to export to LaTeX/PDF as well, you should use grid tables:

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+
| Bananas       | first line\   | first line\        |
|               | next line     | next line          |
+---------------+---------------+--------------------+
mb21
  • 34,845
  • 8
  • 116
  • 142
  • 3
    Sublime Text has a nice package for this: https://packagecontrol.io/packages/Table%20Editor It is no longer maintained, but everything is still fine with it! – fnurl Feb 26 '16 at 06:29
  • 1
    Why didn't they invent this from the very beginning into markdown?! – Endless May 07 '17 at 10:03
  • 3
    I'm using Markdown Preview Extended in VSCode to generate PDF with LaTeX via Pandoc. I put `\newline` (a LaTeX command) inside the table, which passes through because there is an option to allow raw tex. However, this text appears in the preview browser. – Fuhrmanator Dec 11 '19 at 15:20
15

Use <br/> . For example:

Change log, upgrade version

Dependency | Old version | New version |
---------- | ----------- | -----------
Spring Boot | `1.3.5.RELEASE` | `1.4.3.RELEASE`
Gradle | `2.13` | `3.2.1`
Gradle plugin <br/>`com.gorylenko.gradle-git-properties` | `1.4.16` | `1.4.17`
`org.webjars:requirejs` | `2.2.0` | `2.3.2`
`org.webjars.npm:stompjs` | `2.3.3` | `2.3.3`
`org.webjars.bower:sockjs-client` | `1.1.0` | `1.1.1`

URL: https://github.com/donhuvy/lsb/wiki

Vy Do
  • 46,709
  • 59
  • 215
  • 313
15

Just for those that are trying to do this on Jira. Just add \\ at the end of each line and a new line will be created:

|Something|Something else \\ that's rather long|Something else|

Will render this:

enter image description here

Source: Text breaks on Jira

ElChiniNet
  • 2,778
  • 2
  • 19
  • 27
2

I am surprised nobody posted the ascii code for new character in case your renderer does not know about HTML and <br/>, but supports characters like non-breaking space (&nbsp;). So just add new line &#10; or even carriage return &#13; - it may work.

For instance: |Something | Line 1 &#10; line 2 | Something else| works fine in my case, but not in the stackoverflow interpreter...

fabrica
  • 121
  • 1
  • 4