362

I am adding Markdown support to my CMS editor.

When writing Markdown content, how do I create two empty lines?

I have been trying, but I always get only one line.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

17 Answers17

350

If your Markdown compiler supports HTML, you can add <br/><br/> in the Markdown source.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
vmx
  • 7,989
  • 4
  • 22
  • 20
  • 31
    Well, yes but I was wondering if it was possible only in markdown syntax. – Miguel Moura Dec 12 '13 at 12:45
  • 1
    Markdown treats multiple blank lines as one blank line, you could `pre` tag to contain blank lines. As markdown inside `pre` block is not parsed. I would prefer not to do this, instead add as many `
    `'s as needed.
    – vmx Dec 12 '13 at 13:00
  • 29
    It seems to me these tags sort of ruin my document if I want it to also look good as raw text. – Kyle Delaney Oct 25 '17 at 14:43
  • 2
    This answer doesn't seem to work with output to PDF (via xelatex). – Alex Roberts Feb 11 '21 at 14:56
  • The answers languishing down below about using `\` at the end of a line and then making a new line seem better than this answer, since they use Markdown syntax only and keep the document human-readable. It seems not to work with all Markdown libraries, but it should still get more attention than it has so far. – Alex Roberts Feb 11 '21 at 14:58
  • `
    ` without trailing `/` should be sufficient
    – qoomon Feb 28 '23 at 16:24
230

I test on a lot of Markdown implementations. The non-breaking space ASCII character &nbsp; (followed by a blank line) would give a blank line. Repeating this pair would do the job. So far I haven't failed any.

For example:

 

 

Hello

 

 

world!

 

 

pynexj
  • 19,215
  • 5
  • 38
  • 56
ngungo
  • 4,892
  • 4
  • 29
  • 36
  • 13
    Markdown in bitbucket wiki doesn't support this unfortunately – Antony Hatchkins Dec 13 '15 at 09:05
  • This could be an issue in code-blocks, as " " will get rendered as " " – david Nov 30 '16 at 13:16
  • 1
    @david I tried this on the Daring Fireball 'Dingus' page, with block, but with `backticks`, it does get rendered as   where in HTML, it's `&nbsp;` – user3290525 Mar 12 '17 at 14:03
  • I needed to add a space between two tables in a markdown file in TFS/VSTS and this did the trick. Thanks! – Steve L. Jul 24 '17 at 14:30
  • This worked with markdown-deux for Django templates. Thank you! – Encompass Aug 28 '17 at 08:44
  • any suggestions for creating blank pages? (will be needing them for converting multiple `.md` files to a single pdf) – pkaramol Oct 24 '17 at 11:34
  • This worked in RMarkdown in RStudio, but so did the `br` tag, and as I think about what each tag is supposed to mean, I prefer `br` – radumanolescu Jul 08 '19 at 01:20
  • Worked for me with R Markdown pdf output. Thanks. For blank pages, @pkaramol, if you are *inside* a code chunk, use `cat("\n\n\\pagebreak\n")`. Outside a code chunk, check out this post. https://stackoverflow.com/questions/25240541/how-to-add-newpage-in-rmarkdown-in-a-smart-way – Nova Nov 22 '20 at 23:39
74

I only know the options below. It would be great to take a list of all of them and comment them differences

# RAW
## Creates 2 Lines that CAN be selected as text
## -------------------------------------------------
### The non-breaking space ASCII character
&nbsp;
&nbsp;

### HTML <(br)/> tag
<br />
<br />

## Creates 2 Lines that CANNOT be selected as text
## -------------------------------------------------
### HTML Entity &NewLine;
&NewLine;
&NewLine;

### Backticks with a space inside followed by two spaces
`(space)`(space)(space)
`(space)`(space)(space)
#### sample:
` `  
` `

# End
Héctor León
  • 2,210
  • 2
  • 23
  • 36
26

In Markdown flavours that support equation output, the following should work on a line by itself, with empty lines before and after (repeat for more lines):

$~$

It is basically an equation containing nothing but a single equation-white-space. The benefit is that in Markdown flavours that include both PDF and HTML output options (including Rmarkdown), it should be understood in the same way for both output types, whereas I'm not sure how PDF output would interpret <br> or &nbsp;

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Magnus
  • 23,900
  • 1
  • 30
  • 28
24

Basically, if the library you are using is CommonMark-compliant, you can add multiple hard line breaks (<br />) easily. Here's a quotation from CommonMark's latest specifications (0.28):

A line break (not in a code span or HTML tag) that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break (rendered in HTML as a
tag)

and then...

For a more visible alternative, a backslash before the line ending may be used instead of two spaces

The specification is quite clear. However, the library I have been using MarkDig, doesn't quite work with the two spaces technique (must be a bug), but it works flawlessly with a backlash.

That said, this input...

Line one\
\
\
\
Line two

will produce four hard line breaks after "Line one". You can see it here (using backlash)...

https://babelmark.github.io/?text=Line+one%5C%0A%5C%0A%5C%0A%5C%0ALine+two%0A

Notice how all CommonMark-compliant implementations will get it right.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Leo
  • 14,625
  • 2
  • 37
  • 55
12

You can do it perfectly using this:

texttextexttexttext
&nbsp;
&nbsp;
texttexttexttexttext
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Aymen Jarouih
  • 469
  • 5
  • 8
12

You can use <br/><br/> or &nbsp;&nbsp; or \ \.

Aymen Jarouih
  • 469
  • 5
  • 8
9

In GitHub Wiki markdown I used hash marks (#) followed by two spaces to make the line break larger. It doesn't actually give you multiple line breaks but it made one large line break and served me well for my needs.

Instead of:

text
(space)(space)
more text

I did:

text
(hash mark)(space)(space)
more text
Dharman
  • 30,962
  • 25
  • 85
  • 135
Steven Bower
  • 99
  • 1
  • 4
9

Backtick quotes with a space inside and two spaces to follow. Repeat as needed for more lines:

text1 text1
`(space)`(space)(space)
`(space)`(space)(space)
text2 text2

It looks decent in Markdown source:

text1 text1
` `  
` `  
text2 text2
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
greenhyena
  • 99
  • 1
  • 1
  • While this solution works the spaces would show up as actual characters in some markdown flavors such as that of Github – Bobby Axe Dec 28 '20 at 02:29
7
&nbsp;<br>
&nbsp;<br>
&nbsp;<br>

new, three blank line. goodluck

Ahmet atasagun
  • 141
  • 2
  • 6
5

For an empty line in Markdown, escape a space (\ ), and then add a new line.

Example:

"\

"

Remember: escape a space and escape a new line. That way is Markdown compliant and should compile properly in any compiler. You may have to select the example text to see how it is set up.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dfelix
  • 71
  • 1
  • 6
  • 1
    This does not work on Github markdown flavor. There, you have to add html tags

    or however many you need to get the desired effect.
    – dfelix Nov 02 '17 at 05:41
3

You can use the sequence of a no-break space (U+00a0) followed by two spaces (U+0020×2) followed by a newline (U+000a) repeatedly to achieve this. Two or more times is required depending on your use case.

Using (not markdown interpreted here, but) actual white space characters (theoretically copy-and-paste-able):

Preceding
   
   
   
Following.
Jan Kyu Peblik
  • 1,435
  • 14
  • 20
3

I tried everything but this worked for me while using Pandoc markdown with TexLive as LaTex engine. In order to add blank lines, you can try adding a blank line but remove ""

## \newline

Just repeat the above, each will add a new blank line

Dharman
  • 30,962
  • 25
  • 85
  • 135
3
&nbsp;

This HTML entity which means "non-breaking space" will help you for each line break

3

I don't know if it works with other editors, but in VSCode a simple # followed immediately by a newline does the trick for my purposes and can be repeated infinitely. (Unlike the backtick quotes which have zero output there)

It is in fact an empty title line, though - so any document outline or auto-formatting might look funky.

Rautermann
  • 334
  • 3
  • 10
2

If you are using a library like markdown-it or PythonMarkdown this can also be solved by replacing two line breaks (in Regex /\n\n$/gm) with a line break and an invisible character (\n ) before rendering. Note that the character after \n is an Alt+0160 or an invisible character.

For example, using markdown-it (although it work for any other lib too) with the input:

1

2


3


4



5

Rendered with md.render(string.data.replace(/\n\n$/gm, "\n ")) you will get:

enter image description here

adelriosantiago
  • 7,762
  • 7
  • 38
  • 71
  • The invisible character will mess things up involving lists and such by connecting one line to the next. – Seph Reed Mar 10 '21 at 19:59
  • or replace \n\n to some string like 起2643勉 and then after render replace(/起2643勉/gm, "

    ") but stlll issue with its allow one 1 new line 2 new line and 4 new line, 6 new line ;)
    – user956584 Sep 27 '21 at 17:23
-4

Try adding multiple spaces (two spaces = one <br>):

mycode(space)(space)(space)(space)
Dharman
  • 30,962
  • 25
  • 85
  • 135
  • 5
    The OP asked for a markdown technique that would produce two empty lines. Every markdown interpreter that I know of will convert 2+ spaces at the end of a line into a single break, not one break for every 2 spaces. – bazeblackwood Sep 05 '15 at 17:25