HTML Line Break Using the <br> Element

When creating web pages, it's common to create line breaks within a block of text. This is where the HTML <br> element comes in handy. In this article, we'll explore how to use the <br> element to create line breaks in your web pages, with examples and outputs.

The <br> element is a self-closing tag that inserts a line break within the text. This means that anything that comes after the <br> tag will be displayed on the next line. Let's look at an example to illustrate this concept:

1<p>This is the first line of text.<br> 2This is the second line of text.</p>

In this example, the text "This is the second line of text" will be displayed on a new line below the text "This is the first line of text". The <br> element acts as a line break, similar to hitting the enter key on your keyboard.

You can also use the <br> element multiple times to create additional line breaks. For example:

1<p>This is the first line of text.<br><br><br> 2This is the second line of text.</p>

In this example, we have inserted three <br> elements in between the two lines of text. This will create three line breaks and result in a larger gap between the two lines of text.

It's important to note that the <br> element should only be used for line breaks within a block of text. If you want to create larger breaks between sections or paragraphs, it's recommended to use a block-level element like the <div> or <p> element.

In addition, it's good practice to always include a space between the <br> tag and any text that follows it. This ensures that the text is displayed on the line below, rather than immediately next to the line break. For example:

1<p>This is the first line of text.<br> 2 This is the second line of text.</p>

In this example, we have included a space after the <br> tag. This ensures that the text "This is the second line of text" is displayed on the line below, rather than immediately next to the line break.