How to add a line break in Markdown:two spaces, a backslash or a br tag.
You press Enter in a Markdown file, and the two lines show up as one. That is by design. Here is why it happens and the three ways to force a new line.
macOS 14 or later. Reading is free; editing and reviews are one payment.
Quick answer
A single newline in Markdown is treated as a space, so the lines run together. To break the line, end it with two spaces, with a backslash, or put an HTML <br> tag at the end. To start a new paragraph, leave a blank line.
First line\
Second line, after a backslash
Next paragraph, after a blank line
·
Why Markdown ignores your new line
Markdown joins the lines of a paragraph. If you write
Roses are red
Violets are blue
the reader sees one paragraph, Roses are red Violets are blue. The newline in the source is a soft line break: a place where you wrapped the text, not where the reader should see a break. It lets you wrap long lines in your editor without changing how the page looks.
A blank line is different. It ends the paragraph and starts a new one, with space between the two. Most of the time that is the break you want.
Three ways to force a line break
A forced line break, called a hard break, keeps the text in the same paragraph and starts the next line.
-
Two spaces at the end of the line
Type at least two spaces before you press Enter. It works everywhere, but you cannot see the spaces, and some editors and Git settings trim them away.
-
A backslash at the end of the line
Put
\as the very last character, with no space after it. It is visible and survives trimming. It is part of CommonMark and GitHub Flavored Markdown, though a few older apps do not know it. -
An HTML br tag
End the line with
<br>(or<br/>). It works in nearly every app that accepts inline HTML. It is also the only way to break a line inside a table cell.
Two spaces after this line
comes out on a new line.
A backslash ends this one\
and breaks it too.
A tag also works.<br>
Third line.
All three give the same result:
Two spaces after this line
comes out on a new line.
Which one should you use?
- A new paragraph (blank line) for anything that is a separate thought. It is the most portable choice.
- A backslash when you need a break in the middle of a paragraph, such as an address or a poem, and the app follows CommonMark.
- A br tag in a table cell, or when you are not sure the app supports the other two.
- Two spaces only when you are sure nothing will trim them.
Breaks do not work inside a code span, and a break at the very end of a paragraph does nothing. If you want blank space, use a blank line or a heading, not a pile of <br> tags.
Examples: an address, a poem, a list item
A hard break suits text where the line itself matters, such as a postal address:
Jane Smith221B Baker StreetLondon
Jane Smith
221B Baker Street
London
Inside a list item, end the line with the break and indent the next line so it lines up with the item's text:
- Pack the bags and lock the door
- Leave at eight
If every line of a long text needs a break, the text is probably a list or a code block, and Markdown has syntax for both.
When the line break still does not work
- One trailing space. You need two or more.
- A space after the backslash. The backslash must be the last character on the line.
- The editor trims trailing whitespace on save. Switch to a backslash or a br tag.
- The same text looks different in two places. Some apps, such as GitHub issue and comment boxes, keep single newlines as breaks, while a Markdown file on GitHub does not. A forced break looks the same in both.
- Text inside a list item or a quote. Keep the break at the end of the line, then indent the next line to match the item.
The quickest check is to open the file in a reader. DotMD follows these rules: a single newline joins the lines, and two spaces, a backslash or a <br> break the line. Reading is free, and in DotMD Editor the live preview shows the result as you type.
Questions about line breaks in Markdown
How do I add a new line in Markdown?
End the line with two spaces, a backslash or a <br> tag to break inside a paragraph. Leave a blank line to start a new paragraph.
Why is my Markdown new line ignored?
Markdown treats a single newline as a space, so the lines join into one paragraph. Use a blank line, two trailing spaces, a backslash or <br> to get a visible break.
Do two spaces always work for a line break?
In CommonMark and GitHub Flavored Markdown, yes. But editors and Git tools often trim trailing spaces, which silently removes the break. A backslash or <br> is safer.
How do I add a line break in a Markdown table?
Use <br> inside the cell. Two spaces and a backslash do not work there, because a table row is one line of text.