By Alvin Alexander. Last updated: July 30, 2024
In this short article I show a solution for how to display multiple lines of text in a Markdown table cell.
Admittedly this is an ugly solution, but to create an HTML table in Markdown where a cell in the table has multiple lines — i.e., a multiline cell — use the HTML <br>
tag to make the line display as multiple lines, like this:
| Format | Tag example | | -------- | ----------- | | Headings | =heading1=<br>==heading2==<br>===heading3=== | | New paragraph | A blank line starts a new paragraph | | Source code block | // all on one line<br> {{{ if (foo) bar else baz }}} |
I made the <br>
tags in that Markdown text bold so they’re easy to see. That Markdown text produces this HTML table output:
Format | Tag example |
---|---|
Headings | =heading1= ==heading2== ===heading3=== |
New paragraph | A blank line starts a new paragraph |
Source code block | // all on one line {{{ if (foo) bar else baz }}} |
In summary, if you need to have a table cell span multiple lines when writing Markdown, use the HTML <br>
tag, as shown.