4.4 br (Line Break) | HTML

Table of Contents

The <br> element in HTML is used to insert a line break within text or inline content. Unlike block-level elements, which create visible blocks on the page (like paragraphs or headings), the <br> element is an empty element that forces the browser to break the current line of text and move to the next line.

Basic Usage of <br>

The most common use of the <br> element is to create a line break within a paragraph or other inline content where you want to control the placement of line breaks manually.

Example:


<p>This text is on the first line.<br>This text is on the second line.</p>

In this example, the <br> element breaks the line after "first line", forcing "This text is on the second line." to start on a new line.

Why is it Named <br>?

The name "br" comes from "break." It reflects its primary function of breaking a line of text and moving to the next line. In early HTML specifications, elements were often named based on their function or intended behavior to make them intuitive for developers and maintain consistency in naming conventions.

Fun Question:

If you could rename the <br> element, what would you name it and why? Share your creative ideas!

Advanced Usage

While the primary use of <br> is for simple line breaks, it can also be used in conjunction with CSS for more complex layouts or to create spacing between elements where traditional margins or paddings may not apply.

Example with CSS:


<p>This is a line with some text.<br style="line-height: 2;">This line has increased line-height.</p>

In this CSS example, the <br> element is used to increase the line height between lines of text within the same paragraph.

Summary

The <br> element is a simple but essential part of HTML for controlling line breaks within text or inline content. Its name "br" directly reflects its purpose of breaking lines and moving content to the next line, providing flexibility in text formatting and layout.

I am a passionate writer. Read more.

Post a Comment

Don't spam links or promote stuff in the comments. It's annoying and lowers the conversation quality. Contribute respectfully and helpfully instead.