Paragraphs and Line Breaks

Paragraphs are the least visible and most misunderstood structure in Markdown. Many people expect the Enter key in their editor to break a paragraph or start a new line, and are then surprised when the page shows one solid block of text. The reason is worth stating plainly: Markdown does not look at your keystrokes at all. It reads the text of the file, and it splits that text into paragraphs using blank lines and into lines using markers at the end of a line. Nothing else counts.

Once that rule is clear, the rest of the page follows from it. This page covers how paragraphs are separated, why a single newline is not a line break, the three ways to force a real break and how portable each of them is, and how a paragraph interacts with the headings and lists that follow it.

Paragraphs and line breaks

A paragraph is a run of text separated from its neighbours by a blank line. One blank line is enough; extra blank lines are ignored:

This is the first line, with two spaces at the end  
This is the next line in the same paragraph.

This is a new paragraph.
<p>This is the first line, with two spaces at the end<br>
This is the next line in the same paragraph.</p>
<p>This is a new paragraph.</p>

Three rules explain everything else. First, a blank line is what starts a new paragraph; there is no paragraph marker to type. Second, a single newline inside a paragraph is not a line break: HTML collapses runs of whitespace into a single space, so two sentences typed on two lines still appear on one line in the browser. Third, a real line break has to be marked, and the three marks that work are two trailing spaces, a trailing backslash, or an HTML break tag:

first line  
second line

first line\
second line

first line<br>
second line
<p>first line<br>
second line</p>
<p>first line<br>
second line</p>
<p>first line<br>
second line</p>

All three produce the same output, but they differ in how portable and how visible they are.

  • Two trailing spaces are the classic form. They work in every CommonMark renderer, but they are invisible: no editor marks them, no error is raised, and many editors and formatters strip trailing whitespace when they save the file. When they are stripped, the line break silently disappears with them.
  • A trailing backslash produces exactly the same output and is at least something you can see in a diff. It has been part of the CommonMark specification for a long time, though a few older tools still do not recognise it. It only marks a break at the end of a line; inside a code span it is an ordinary character.
  • An HTML break tag is raw HTML rather than Markdown syntax. It works in most renderers, but it is not part of the Markdown standard, and renderers that filter HTML will drop it. In toolchains built on MDX, where a bare angle-bracket tag is parsed as a component, it has to be written as a proper JSX element instead.

Horizontal rules

A line consisting of at least three dashes, asterisks, or underscores, standing on its own, becomes a horizontal rule:

The paragraph above.

---

The paragraph below.

The parser replaces that row of dashes with a horizontal rule element (<hr>), so the two paragraphs end up separated by a rule. The rule has to own its line, with blank lines around it, otherwise it is absorbed into the neighbouring block. Be aware that a row of dashes is also the Setext underline for a level 2 heading, which is why a rule placed directly under a line of text turns that text into a heading instead.

Paragraphs and the blocks that follow

A paragraph is an open block: it keeps absorbing lines until something closes it. A blank line closes it, and so do the block elements that can interrupt it. A heading always interrupts a paragraph and needs no blank line in front of it, and a bullet list can interrupt one too:

Some text
## Heading

Some text
- item one
<p>Some text</p>
<h2>Heading</h2>
<p>Some text</p>
<ul>
<li>item one</li>
</ul>

An ordered list is pickier: it may only interrupt a paragraph when it starts at 1, otherwise the numbers are just more text in the paragraph. Indentation is the one case where a blank line really matters. Four spaces at the start of a line that follows a blank line turn the text into a code block, while the same indentation on a line that continues a paragraph is only a continuation of it. That is the reason an over-indented paragraph disappears from the page: the parser reads it as code, and the reader sees a monospaced block instead of your text.

Paragraph text.

    indented four spaces
<p>Paragraph text.</p>
<pre><code>indented four spaces
</code></pre>

Common pitfalls

SourceWhat you expectedWhat rendersWhy
pressing Enter inside a paragrapha new lineone line, whitespace collapsedHTML collapses whitespace
two trailing spaces at the end of a linea visible line breaka line break with no visible markerthe trailing spaces are the marker
a trailing backslasha line breaka line breakalso a hard break mark, but a visible one
four spaces of indentation after a blank lineindented texta code blockfour spaces mean code
--- directly under a line of texta horizontal rulea level 2 headingthe Setext underline wins
--- directly under an ATX headinga setext headinga horizontal rulea setext underline applies to paragraphs only
a bullet list right after a paragrapha continuation of the texta separate lista list can interrupt a paragraph
2. right after a paragrapha listmore text in the paragraphan ordered list may only interrupt when it starts at 1

Exercises

Write the Markdown source for the text below. The first two lines must appear on two separate lines of the same paragraph, and the third sentence must become a paragraph of its own.

First line
Second line

Third sentence
ParagraphsHard line breaksBlank line separation

Approach:

The first two lines belong to one paragraph but must be displayed on two lines, so they need a hard break marker. The third sentence starts a new paragraph, and a paragraph is created by a blank line rather than by any symbol. Using two trailing spaces is the most standard choice; a trailing backslash would work equally well.

Steps:

  1. Put two spaces at the end of the first line to force the break.
  2. Write the second line immediately after it, with no blank line in between, so both stay in one paragraph.
  3. Leave one empty line after the second line; that is what separates the paragraph, then write the third sentence with no leading symbol or indentation.
  4. Check the result: the first two lines share a paragraph and the third one starts a new block.

Answer:

First line  
Second line

Third sentence

Summary

You should now be able to explain the single rule behind the whole page, namely that blank lines separate paragraphs and markers at the end of a line separate lines, and you should be able to predict which of the three hard break marks survives a trip through your editor, your formatter, and your renderer. You should also be able to spot the two ways a paragraph turns into something else by accident: four spaces of indentation that make it code, and a row of dashes that turns the line above it into a heading. When you write longer prose from now on, you will separate paragraphs with a blank line on purpose instead of relying on an editor setting you cannot see.

Found an issue with this content?

Tell us what could be improved.