Markdown Line Breaks
You press Enter in a Markdown file, preview it, and the two lines have merged into one. That's normal. In Markdown a single Enter doesn't create a new line on the page. To get a visible line break you need one of three things: two spaces at the end of the line, a backslash, or an HTML <br> tag.
Which one is right depends on where the Markdown will be shown. A GitHub README, a GitHub issue, a table cell and a docs site built with MDX each handle line breaks a little differently, and this page covers all of them.
Looking for a blank line between blocks of text? That's a paragraph break, and it has its own page: Markdown Paragraphs. New to Markdown? Start with Markdown Basics.
π‘ Practice as you read: Open the Markdown Editor for live preview.
Quick Answer
- Two spaces + Enter: the original Markdown way. Works in most parsers, but the spaces are invisible and editors like to delete them.
- Backslash + Enter: same result, and you can see it in the source. Part of CommonMark and GitHub Flavored Markdown (GFM). Older parsers may print the backslash.
<br>: works wherever the platform allows inline HTML. The only option inside a table cell.- Blank line: not a line break. It starts a new paragraph.
The Four Ways, One at a Time
1. Just pressing Enter (a soft break)#
This is line one.
This is line two.
Renders as one paragraph: This is line one. This is line two.
The parser treats the newline as a soft break. Browsers collapse it into a space, so the two lines run together. This is fine for keeping source files tidy with short lines, and useless when you actually want the break to show.
2. Two trailing spaces#
First line.Β·Β·
Second line.
(Β·Β· stands for two spaces. They're shown here only so you can see them.)
Renders as:
First line.<br> Second line.
Two or more spaces before the line ending make a hard break. The catch is that nobody can see them. Plenty of editors strip trailing whitespace when you save, and some linters complain about it, so the break can disappear without you touching the file.
3. A backslash at the end of the line#
First line.\
Second line.
Renders as:
First line.<br> Second line.
CommonMark defines this and GFM supports it. Because the backslash sits in plain sight, nothing can quietly remove it. Parsers that predate CommonMark may not know the rule and will show the backslash as text, so preview before you rely on it in an older toolchain.
4. The <br> tag#
First line<br>
Second line
or on one line: First line<br>Second line
Renders as:
First line<br> Second line
This works wherever the platform lets HTML through, which includes GitHub. It is also the only method that works inside a table cell. In MDX (used by Docusaurus and similar tools) write it as <br />, because MDX treats HTML as JSX and wants the tag closed.
Line Break or Paragraph Break?
A line break moves text to the next line inside the same paragraph. A paragraph break, a blank line, starts a new block with spacing around it.
For normal writing you want paragraph breaks. Line breaks are for text where the line itself matters: an address, a poem or song verse you own, a signature block.
Where Each Method Works
| Where | Single Enter | Two spaces | Backslash | <br> |
|---|---|---|---|---|
GitHub README and .md files |
Joins into one line | Works | Works | Works |
| GitHub issues, PRs and comments | Becomes a line break | Works | Works | Works |
| CommonMark parsers | Joins into one line | Works | Works | Only if raw HTML is enabled |
| VS Code Markdown preview | Joins (default) | Works | Works | Works |
| Obsidian | Becomes a line break (default) | Works | Works | Works |
| MDX / Docusaurus | Joins into one line | Works | Works | Needs <br /> |
The GitHub row is the one that confuses people. The same text can look right in an issue and wrong in the README, because comments keep your single line breaks and files don't. If you write a draft in an issue and copy it into a README, the breaks vanish.
Line Breaks Inside a Table
A table row ends where the line ends, so Enter, trailing spaces and backslashes can't help inside a cell. Use <br>:
| Office | Address |
|---|---|
| Main | 12 Example Road<br>Springfield<br>Pin 000000 |
| Support | 4 Sample Street<br>Shelbyville |
Each <br> puts the next piece of text on a new line inside the cell. If your platform strips HTML, you can't have multi-line cells in a Markdown table at all, and the fix is to split the cell into separate columns or rows. Table basics are in Markdown Tables.
Line Breaks Inside a List Item
Indent the continuation line so it lines up with the text after the bullet, and end the line above it with a backslash or two spaces:
- Pack the charger\
and the cable
- Lock the door
The first item shows on two lines, the second on one. Without the indent, the second line would fall out of the list. More list rules are on Markdown Lists.
Adding Extra Empty Space
Several blank lines in a row collapse into one paragraph gap, and stacked <br> tags are fragile. If you really need a visible empty line, put on a line of its own between two paragraphs. Use it sparingly. Needing it a lot usually means the layout belongs in CSS or the platform's own formatting.
My Line Break Isn't Working
Go through these in order, from most to least likely:
- You pressed Enter once. That's a soft break. Add two spaces, a backslash or
<br>. - Your editor removed the trailing spaces. Check the setting that trims whitespace on save. In VS Code that's
files.trimTrailingWhitespace, and many people turn it off for Markdown files only. EditorConfig'strim_trailing_whitespacedoes the same job. If you can't change it, switch to the backslash. - The break is at the end of a paragraph. A hard break needs text after it. Trailing spaces at the end of a paragraph are stripped, and a backslash there just prints as a backslash.
- You left a blank line. That made a new paragraph, not a line break.
- The platform strips HTML. Then
<br>is removed and the lines merge. Try the backslash. - It's MDX.
<br>breaks the build or is ignored. Use<br />. - The parser doesn't know the backslash rule. You'll see a literal
\. Use two spaces or<br>. - You're in a heading. A heading is one line. Trailing spaces at the end of a setext heading line don't create a break either.
Make a Single Enter Work as a Line Break
Some people want every Enter to count, the way it does in a chat box. Most renderers have a switch for this:
| Tool | Setting |
|---|---|
| VS Code preview | "markdown.preview.breaks": true |
| Obsidian | Already on by default. The "Strict line breaks" option in Editor settings turns it off |
| Hugo (Goldmark) | hardWraps = true under [markup.goldmark.renderer] |
| markdown-it | markdownit({ breaks: true }) |
| marked | marked.use({ breaks: true }) |
| Python-Markdown | Add the nl2br extension |
Be careful with this when other people read your files. A document written for a renderer with this switch on will run its lines together everywhere else.
Which One I'd Pick
For text that other tools will render, I'd use the backslash if the platform is CommonMark-based, because it's visible and it survives a trailing-whitespace cleanup. If I can't be sure of the parser, <br> is the safest, as long as HTML is allowed. Two spaces are the oldest method and the easiest to lose, so I'd only use them in files nobody will auto-format.
Real Examples
Address in a README footer
MDConvertHub\
New Delhi\
India
Verse from a poem you wrote
The sun will rise,\
the birds will sing,\
a new day begins.
Several short lines in a table cell
| Plan | Includes |
|---|---|
| Free | Editor<br>Live preview<br>Export |
Changelog entries. Don't use line breaks for these. A list does the job and reads better in raw text:
## Version 2.0
- Faster conversion
- Fixed export bug
- Added table support
Common Mistakes
| Mistake | What happens | Fix |
|---|---|---|
| One Enter, expecting a new line | Lines merge | Two spaces, backslash or <br> |
| Trailing spaces in a file that gets auto-formatted | Breaks vanish after save | Use the backslash |
| Backslash at the very end of a paragraph | Backslash prints as text | Put it before the last line, not on it |
| Newline inside a table cell | Row breaks apart | <br> |
<br> in MDX |
Build error or ignored | <br /> |
Piles of <br> for spacing |
Fragile layout | Paragraph break |
| Using line breaks for a list of items | Hard to maintain | Use a real list |
Frequently Asked Questions
- 1
How do I add a line break in a Markdown table cell?
Use
<br>inside the cell. Enter, trailing spaces and backslashes can't be used there because the table row ends at the end of the line. - 2
Why do my lines look joined on GitHub even though they're on separate lines in the file?
In README files and other
.mddocuments a single newline is a soft break and shows as a space. In issues, pull requests and comments GitHub keeps single line breaks. Add a backslash, two spaces or<br>if you need the break in a file. - 3
Do I need two spaces, or will one do?
It needs two or more. A single space before the line ending does nothing.
- 4
Is the backslash method safe to use everywhere?
It's part of CommonMark and GFM, so modern renderers handle it. Very old parsers may print the backslash. If you don't know the renderer, use
<br>or test first. - 5
Can I put a line break inside a heading?
Not with spaces or a backslash. A heading sits on one line. If your platform allows HTML,
<br>is the usual workaround. - 6
What's the cleanest way to make a gap between two lines?
A blank line. It makes two paragraphs. For anything more,
on its own line works, but needing it often is a sign to restructure.
