This content originally appeared on HackerNoon and was authored by Typesetting
Line Breaks
To create a line break or new line (<br>
), end a line with two or more spaces, and then type return.
\
| Markdown | HTML | Rendered Output |
|----|----|----|
| This is the first line.
\n And this is the second line.
| <p>This is the first line.<br>
\n And this is the second line.</p>
| This is the first line. \n And this is the second line. |
Line Break Best Practices
You can use two or more spaces (commonly referred to as “trailing whitespace”) for line breaks in nearly every Markdown application, but it’s controversial. It’s hard to see trailing whitespace in an editor, and many people accidentally or intentionally put two spaces after every sentence. For this reason, you may want to use something other than trailing whitespace for line breaks. If your Markdown application supports HTML, you can use the <br>
HTML tag.
\
For compatibility, use trailing white space or the <br>
HTML tag at the end of the line.
\
There are two other options I don’t recommend using. CommonMark and a few other lightweight markup languages let you type a backslash (\
) at the end of the line, but not all Markdown applications support this, so it isn’t a great option from a compatibility perspective. And at least a couple lightweight markup languages don’t require anything at the end of the line — just type return and they’ll create a line break.
\
| ✅ Do this | ❌ Don't do this |
|----|----|
| First line with two spaces after.
\n And the next line.
\n \n First line with the HTML tag after.<br>
\n And the next line.
| First line with a backslash after.\
\n And the next line.
\n \n First line with nothing after.
\n And the next line.
|
\
:::info This guide is a Matt Cone project available on Markdown Guide under the CC BY-SA 4.0 license.
:::
\
This content originally appeared on HackerNoon and was authored by Typesetting
Typesetting | Sciencx (2024-08-20T15:48:54+00:00) The Dead Simple Markdown Guide to Line Breaks. Retrieved from https://www.scien.cx/2024/08/20/the-dead-simple-markdown-guide-to-line-breaks/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.