Adding line breaks in your HTML using the <br> tag is a simple way to make your text more readable.
The <br> tag will insert a line break wherever you put it within your code.
What is the <br> tag?
The <br> tag is a self-closing tag that inserts a line break wherever it is placed within your code. To use the <br> tag, simply add the <br> tag wherever you want a line break to appear in your code.
Here is an example of how the <br> tag can be used:
<p>This is a paragraph.<br> This is another line in the same paragraph.</p>
In the example above, the <br> tag is used to insert a line break between the two lines of text, all within the same <p> element.
This is what the text will look like:
This is a paragraph.
This is another line in the same paragraph.
Here are some tips and for using <br> tags in HTML code. Note that these are "quick and dirty" approaches for making text look the way you want. As you get better with HTML, you will want to use CSS to style your text.
Tip #1: Use <br> tags to create line breaks in text, instead of using multiple paragraphs or other elements. This can be simpler and easier to maintain.
Tip #2: Use <br> tags to create extra space between lines of text
Tip #3: Use <br> tags to create extra space between elements on a page. That's right – you can just brute-force inserting empty vertical space by typing
<br><br><br>. Not recommended, but if you're in a hurry, I won't judge you.
Tip #4: And the most important best practice is, again, use <br> tags sparingly, and only when necessary.
Go forth and break some HTML
The <br> tag is a simple and easy way to add line breaks to your HTML code. By adding the <br> tag wherever you want a line break to appear, you can make your code more readable and easier to understand.
I hope you've found this helpful. If you want to learn more about programming and technology, try freeCodeCamp's core coding curriculum. It's free.