Markdown is a relatively straightforward language, and it doesn’t depend on any specific platform. With Markdown, we can write anything, including web pages, papers, notes, and more. In Markdown, we may write texts or headings and format them in many ways, such as bold, italic, etc. By using this Markdown language, we can also insert images, links, lists, etc. When we are writing text in Markdown, we need to add a new line in this text. For adding a new line in our text, we may use different methods in Markdown. In this tutorial, we will utilize different techniques that help in adding a new line or multiple lines in the Markdown text.
Techniques Utilized for Adding a new Line in Markdown:
We may utilize some symbols or HTML tags for adding a new line in Markdown. The techniques which help in adding a new line are discussed below.
- By using the HTML <br/> or <br> tag.
- By using the backslash \ symbol.
- By adding an empty line.
- By inserting two spaces and then pressing enter.
We will apply these techniques in this tutorial and will add one or more new lines to our Markdown’s code. We will explore all techniques in detail here.
Example # 01: By Utilizing the HTML <br/> Tag
The software we are utilizing in this tutorial is “Visual Studio Code,” in which we have opened the text file and also the preview window. We just type the code in the text file after choosing the language as “Markdown,” and the result is displayed simultaneously in the preview window. We just add a single line to the input, but we also want to display half the text of this line in the next line.
Here, we want to display the text “by using the HTML tag” in the next line, so, for this, we use the HTML tag which is the “<br/>” tag here, and add this tag where we want to insert the next line, and the text which is written after this tag will appear on the next line. See that we have added the “<br/>” tag in between the lines. Now this line’s text will be divided into two lines and the text which is written after this tag will appear on the next line in the outcome.
The preview window shows that the above line is rendered into two lines. The new line is added here because of the “<br/>” tag that we have used above.
Example # 02:
Now, we are adding three new lines to this code. For adding three new lines in Markdown, we are using three “<br/>” tags here. We have written a line, and in this we put three tags. So, three new lines are added and displayed in the preview window as a result of this code.
The text which we have added before the “<br/>” tags is shown in the first line, then three new lines are added there. The remaining text that we have added after the “<br/>” tags is displayed below after adding three line gap.
Example # 03: By Using the “\” Symbol
We are adding one line and then putting two backslashes “\” there in two different lines. The purpose of these backslashes is to add two new lines, and then we have to write another line after adding the backslashes. Now, move ahead and check the result of this code in the preview window.
The first line is displayed, and then two new empty lines are shown here. This is because we have added the backslashes in the code above, and the second line is rendered after these two new lines.
Example # 04:
Here, we have added the backslash in between the first line and second. So, it will not add the new line here. Following that, we added the backslash in the next line and typed the remaining text with this backslash in the same line so that the new line was not added. Then we have written two lines in two different lines but both lines will appear in one line. Now, at the end, we have added the backslash, and then press enter and write another line in the new line.
See here, the backslash in the first line is also rendered in this outcome, and the new line is not added there. After this, the new line is not added below, because we have added the backslash and the second line in the same line. The third line is also rendered in only one line, but in the fourth line, the same text is rendered in two lines because we have added the first line. Then in the second line, we have added the backslash, and the remaining text is added in the next line after adding the backslash.
Example # 05: By Adding an Empty Line
We write one line and then we insert an empty line in this code. After adding this empty line, we then add another line in the next line. Now, the new line is simply added in this way.
Here, the new line is simply displayed in this outcome as we have added this new line in the code which is also displayed above.
Example # 06: By Adding Two Spaces and Pressing Enter
We have written “Line num 1” in the first line, and then added two spaces. By pressing enter, we move to the next line. In this second line, we have written: “Line num 2” which will also be displayed in the new line in the output. If we don’t add two spaces after the first line, then both lines will appear on the same line.
As we have entered two spaces after the text “Line num 1” and then pressed enter, the next line we have written above is shown in the next line.
Example # 07:
Here, we have entered the first line and just pressed enter. We then move to the next line, and we have entered the second line there. Both lines will appear in one line, and the next line will not add to the outcome because we didn’t add two spaces after completing the first line. Below, we have again entered one line, but this time, we add two spaces after completing this line and then press enter. After this, we have written another line below this. Now the text which we have added after entering two spaces and by pressing enter will appear in the new line.
Note that the first line, which is rendered here, is added in two different lines in the code above. But here, in the outcome below, all the text from both lines is displayed in only one line because we haven’t added two spaces after this first line. Below, the two lines are shown as two separate lines because we have added two spaces after writing the first line completely. So, the new line is added there.
Conclusion:
We have presented this tutorial here because we want to explore the concept of “markdown adds the new line” in detail. This tutorial explains multiple techniques for adding a new line as well as adding multiple lines in Markdown. We have discussed the “<br/>” tag of the HTML for adding a new line and also the “\” backslash symbols are explored in detail. Also, we have explained that we can simply add a new line by adding two spaces after the first line and pressing enter, and then adding another line. We have explored all the techniques here and have shown how we have added the new line in the Markdown codes.