Language: EN

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

Paragraphs and Line Breaks in Markdown

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 that might drive you a bit crazy. Markdown is “very particular” about spaces. So pay attention👇

Basic Paragraphs

A paragraph in Markdown is created simply by writing the 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.

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 beginning 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.

This renders as:

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

In other words, if your little head expected to have two paragraphs, ”📣 Mooock, error 💥“. In Markdown, they are all together, unless you put a blank 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 (after “with a” there are two spaces, although you can’t see them).

This is the first paragraph with a  
line break.

This renders as:

This is the first paragraph with a
line break.

Example with backslash:

This is the first paragraph with a \
line break.

This also renders as:

This is the first paragraph with a
line break.

Since using two spaces is very problematic (basically because they are not visible 😆) I recommend not using it, and using a blank line, or at the very least the backslash \.

Line Breaks in Markdown

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: “hard wrap” style and “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 what 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 looks good.

Best Practices Tips

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

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