You are currently viewing Correct HTML element for Inserting a Line Break
  • Post category:HTML

Correct HTML element for Inserting a Line Break

What is the correct HTML element for inserting a line break

You can create line break using HTML <br> tag. You don’t need to use any styles to display a paragraph on the next line. This article is about what is the correct HTML element for inserting a line break

What is a line break?

Breaking the displayed content on a single line is called a line break. To break lines you need to use an HTML break tag. We use the paragraph <p> tag to write poetry lines, address, song lyrics, etc in HTML but it will be displayed on a single line even if it is written on the next line in HTML. So, in that situation, you can use the <br> tag wherever you want a line break within the <p> tag.

What is a break tag?

<br> is one of the useful tags in HTML, It is an unpaired tag, so you don’t need to use a closing break tag. It is used to break a line in an HTML text. According to my online research, I learn that it is generally used in poems and addresses. However, I found that it is also being used in other topics. If we insert the two <br> tag continuously, an empty line will be created. Instead of creating multiple <p> tags to display content on subsequent lines, to break a line you need to use the <br> tag inside the <p> tag.

Correct HTML element for inserting a line break

The correct HTML element for inserting a link break is the <br> element.

In the code below, I have placed each line inside a <p> tag to display the quotes on a separate line. If you create a separate p tag as in this code, extra space will be automatically created for each line as in the output. And by doing this we are wasting our time, So you should not use it like this.

<p>Life is about moments:</p>
<p>Don't wait for them</p>
<p>Create them!</p>

Output:

READ ALSO  Which Character is Used to Indicate an end tag in HTML?

what is the correct html element for inserting a line break

So, you use the below method to display your content on each line. In the code below, the <br> break tag is used only where a break is required within a <p> paragraph tag.

<p>Life is about moments:<br>
Don't wait for them<br>
Create them!</p>

Output:

what is the correct html element for inserting a line break

Conclusion

So instead of creating a separate <p> element for each line, you use the <br> tag only where you need a linebreak within the same <p> element.

Leave a Reply