How to make a new line in markdown

Updated

Markdown collapses a single newline into a space: pressing Enter once does not start a new line in the output. To force a line break inside a paragraph, end the line with two spaces or a backslash; to start a new paragraph, leave a blank line:

Line one ends with two spaces··
Line two is in the same paragraph, on its own line.

A blank line starts a new paragraph.

Line one ends with two spaces
Line two is in the same paragraph, on its own line.

A blank line starts a new paragraph.

(The ·· above stands for two real spaces, which are invisible in the source.) That is the whole of the standard behaviour, defined as soft and hard line breaks in CommonMark. The complications are the renderers that treat every newline as a break (GitHub comments, Obsidian by default, chat apps) and the two places where none of the paragraph syntax works: table cells and the first line of a list item.

What's the difference between a line break and a paragraph?

A line break (<br>) keeps the next line inside the same block, with no extra vertical space: an address, a verse, a sign-off. A paragraph (<p>) is a new block with a margin above it. Choose by how much separation you want:

You wantWriteHTML produced
Next line directly under this oneTwo trailing spaces, or \ at the end of the line<br> inside the same <p>
A new paragraph with spacingOne blank lineA new <p>
The lines joined into oneJust press Enter once (in a .md file)Nothing; the newline becomes a space
Visible vertical gap, no text<br> on its own line, where HTML is allowedAn empty line's worth of space

Multiple blank lines in a row are the same as one; markdown has no "double paragraph break".

Is there an alternative to invisible trailing spaces?

Yes, two. A backslash at the end of the line is a CommonMark hard break and, unlike trailing spaces, survives editors and formatters that trim whitespace on save, which is why most style guides prefer it:

Line one\
Line two

The second alternative is the HTML <br> tag, which works wherever inline HTML is allowed and is the only option inside a table cell. Its weakness is the platforms that strip HTML (Slack, Discord, Reddit), where it prints as text. The three forms compared:

FormStandardSurvives whitespace trimmingWorks in table cellsWorks where HTML is stripped
Two trailing spacesCommonMarkNoNoYes
Backslash \CommonMarkYesNoYes
<br>HTMLYesYesNo

In MDX the tag must be self-closing (<br />); a bare <br> fails the build.

Why does my new line work on GitHub but not elsewhere?

Because some renderers treat every single newline as a hard break ("soft break as hard break"), and others follow the spec. GitHub does both, depending on where you are typing: its docs state that in issues, pull requests and discussions a newline renders as a line break, while in .md files it does not. So a block of text written in a PR description reflows into one paragraph when pasted into a README. Use explicit breaks (backslash, trailing spaces or <br>) and it renders the same everywhere.

How do you make a new line in Slack, Discord, Notion, Obsidian and the rest?

AppLine break in the editorIn the source / APINew paragraphSource
GitHub .md filesTwo spaces, \, or <br>SameBlank lineGitHub line breaks
GitHub issues, PRs, discussionsEnterA newline is a breakBlank lineSame page
GitLabTwo spaces, \, or <br>Single newline stays in the paragraphBlank lineGitLab line breaks
ObsidianEnter (default); Shift+Enter always"Strict line breaks" setting off by default, so a newline is a break; on, it follows CommonMarkBlank lineObsidian syntax
NotionShift+Enter inside a blockEnter creates a new blockEnterNotion shortcuts
SlackShift+Enter\n in the message textShift+Enter twiceSlack formatting
DiscordShift+EnterA newline is a breakShift+Enter twiceDiscord formatting
RedditEnter in the rich editor; two trailing spaces in markdown modeSingle newline collapses in markdown modeBlank lineReddit markdown sheet
Jira CloudShift+Enter\\ in legacy wiki markupEnterJira shortcuts
MDXTwo spaces, \, or <br />Follows CommonMarkBlank lineMDX docs
PandocTwo spaces or \; --from markdown+hard_line_breaks makes every newline a breakFollows CommonMark by defaultBlank linePandoc manual

The Slack markdown sheet, Discord markdown sheet, Obsidian markdown sheet and Notion markdown sheet cover the rest of each app's syntax.

How do you add a line break inside a table cell or a list item?

In a table cell, only <br> works. A cell must stay on one source line, so trailing spaces and backslashes have nothing to break:

| Step | Commands |
|---|---|
| Build | `npm install`<br>`npm run build` |

In a list item, a trailing backslash or two spaces breaks the line, and the continuation must be indented to the item's content column (2 spaces for -, 3 for 1.) or it leaves the list:

- First line of the item\
  second line of the same item
- Next item

A blank line followed by an indented paragraph starts a new paragraph inside the item; the indent guide and nested list guide cover the column rules.

How do you add extra blank space between paragraphs?

Markdown ignores extra blank lines, so stacking them does nothing. Where HTML is allowed, put <br> on its own line between the paragraphs, one per extra line of space; where it is not, there is no way to widen the gap, because the gap belongs to the renderer's stylesheet. A horizontal rule (---) is the markdown-native way to mark a larger break between sections, and a heading is usually the better answer if the extra space was meant to signal a new topic. In Pandoc exports to docx or PDF, paragraph spacing is set in the reference document or template, not in the markdown.

Which line-break syntax should you use?

The backslash, unless the document is going somewhere that treats it as a literal character. It is standard, visible in the source and immune to whitespace trimming. Trailing spaces are the original syntax and still work everywhere CommonMark does, but they are invisible, and markdownlint's MD009 flags them by default (it allows exactly two when configured). <br> is for table cells and for docs tools where you also need <br> elsewhere. In chat apps none of the three apply; use Shift+Enter.

Why is my line break not working?

  1. One trailing space, not two. A single space is a soft break. Use the backslash to avoid counting.
  2. The editor trimmed the spaces. Most editors strip trailing whitespace on save. Use the backslash.
  3. Inside a table cell. Only <br> works there.
  4. <br> where HTML is stripped. Slack, Discord and Reddit show the tag. Use the app's Shift+Enter.
  5. You are in a code block. Newlines in code are preserved exactly, and markdown syntax is not parsed, so a \ is just a backslash.
  6. A backslash before a space. \ at the end of a line is an escaped space, not a break; the \ must be the last character.

The markdown viewer renders with GitHub's .md-file rules, so if the break shows there, it will show in a README. For the full syntax see the markdown cheat sheet.

Keep going