parrafos-y-saltos-de-linea-en-markdown

Paragraphs and Line Breaks in Markdown

  • 3 min

One of the most basic and essential features of Markdown is how it handles paragraphs and line breaks.

At the same time, it’s one of the most “peculiar” things and something that will sometimes drive you crazy. Markdown is “very particular” about spaces. So pay attention, here we go👇

Basic Paragraphs

A paragraph in Markdown is created simply by writing text on continuous lines. To separate paragraphs, you must leave a blank line between them.

Example:

This is the first paragraph.

This is the second paragraph.
Copied!

This renders as:

This is the first paragraph.

This is the second paragraph.

Importance of Blank Lines

Blank lines are crucial to indicate the end of one paragraph and the start of another. Without a blank line, the text is considered part of the same paragraph.

Incorrect example (without a blank line):

This is the first paragraph.
This is the second paragraph.
Copied!

This renders as:

This is the first paragraph. This is the second paragraph.

That is, if your little head expected to have two paragraphs, ”📣 Mooock, error 💥”. In Markdown they are all together, unless you put an empty line in between.

Line Breaks Within a Paragraph

To insert a line break within the same paragraph, you use two spaces at the end of a line or a backslash (\).

Example with two spaces (there are two spaces after “with a”, although you can’t see them).

This is the first paragraph with a  
line break.
Copied!

This renders as:

This is the first paragraph with a
line break.

Example with backslash:

This is the first paragraph with a \
line break.
Copied!

This renders equally as:

This is the first paragraph with a
line break.

Since using two spaces is very problematic (basically because you can’t see them 😆) I recommend you don’t use it, and use the empty line, or as a last resort the backslash \.

Line Breaks in Markdown

Actually, ultimately, the way line breaks are interpreted will depend on the Markdown style used by the application we are using.

There are two main styles: the “hard wrap” style and the “soft wrap” style.

Soft Wrap

In the soft wrap style, line breaks in the source text are ignored and the text is considered to continue on the same line.

This is the default behavior in most Markdown implementations (and it’s the one we’ve seen in this article).

Hard Wrap

In the hard wrap style any line break in the source text is considered a line break in the rendered document.

Keep in mind that different platforms and editors may handle line breaks differently. It’s best to test your document on the platforms where it will be used, to ensure it will look good.

Best Practices Tips

Readability: Use line breaks and paragraphs to improve text readability. Long paragraphs can be hard to follow, so it’s advisable to break them into shorter paragraphs.

Clarity: Make sure the intention of line breaks and paragraphs is clear. Use blank lines to separate distinct ideas and two spaces or a backslash for line breaks within a paragraph.