Blog · Guide

Line Breaks in Markdown: Complete Guide

May 31, 2026 · 5 min read
advertisement

Line breaks in Markdown behave differently from what most word processor users expect. A single press of Enter doesn’t always create a visible line break — and understanding why is one of the most common stumbling blocks for Markdown beginners.

The Basics: Paragraphs vs. Line Breaks

In Markdown, a blank line (pressing Enter twice) creates a new paragraph:

This is the first paragraph.

This is the second paragraph.

Both blocks render as separate <p> elements with a gap between them.

A single newline in source text is treated as a space in most parsers — it continues the same paragraph:

This line
and this line
are the same paragraph.

Renders as: “This line and this line are the same paragraph.”

This surprises people coming from Word or Google Docs, where Enter always moves to a new line.

Hard Line Break: Two Spaces

The standard Markdown way to force a line break within a paragraph is two or more trailing spaces before the newline:

First line of a stanza  
Second line of the same stanza  
Third line still together

The two spaces at the end of a line create a <br> element — a visual line break without starting a new paragraph.

This is subtle and easy to miss because most text editors strip trailing whitespace. If your line breaks aren’t working, this is often why.

Hard Line Break: Backslash

The backslash at the end of a line is supported by many parsers (GitHub, Pandoc, VS Code preview) as an alternative to trailing spaces:

First line\
Second line\
Third line

This is more visible in source text than invisible trailing spaces, which makes it the preferred choice when writing poetry, addresses, or other content where line structure matters.

Note: backslash line breaks are CommonMark-compliant but not supported by all parsers. Trailing spaces are more universally supported.

HTML <br> Tag

Raw HTML works inside most Markdown documents:

First line<br>Second line

Or more explicitly:

First line<br />Second line

This is the most reliable approach when you need a line break and aren’t sure which parser your text will flow through. It works everywhere HTML is rendered.

GitHub and CommonMark Behavior

GitHub Flavored Markdown (GFM) has a setting that converts every single newline in paragraphs into a <br>. This is the “hard wrap” mode — designed for casual writing where every Enter means a new line.

Standard CommonMark does not do this. A single Enter is whitespace.

If your Markdown looks different on GitHub vs. in your local editor, this is often the cause.

When Line Breaks Don’t Matter

In prose writing — articles, documentation, README files — paragraph breaks (blank lines) are almost always what you want. The exact line wrapping of source text rarely affects the output meaningfully.

Line breaks matter most in:

  • Poetry and song lyrics — where line breaks are semantic
  • Postal addresses123 Main Street\nCity, Country
  • Code comments embedded in Markdown
  • Tables — where <br> is the only way to add content to a new line within a cell

Comparison Table

MethodSyntaxCompatibility
Paragraph breakBlank lineUniversal
Trailing spacestext··\n (two spaces)Universal
Backslashtext\ + newlineCommonMark, GitHub, VS Code
HTML <br><br>Universal (where HTML is allowed)
Single newlineJust press EnterRenders as space in most parsers

Common Mistakes

Relying on single newlines — Most parsers treat a single newline as a space. Use blank lines for paragraphs, trailing spaces or \ for in-paragraph line breaks.

Editor stripping trailing spaces — VS Code, Sublime Text, and many others are configured to remove trailing whitespace on save. If two-space line breaks keep disappearing, check your editor settings.

Confusing soft and hard wraps — Text that wraps visually in your editor (soft wrap) is not a hard line break in the output. Only explicit syntax (trailing spaces, \, <br>) creates a visible break.

Try It

Test line break behavior in the Markdown Monk editor — the live preview shows exactly how your breaks will render before you export to PDF, DOCX, or HTML.

Free tool

Try it in the editor

Test every syntax example above — live in your browser, free, no sign-up.

Open editor → More guides →