<br>

Definition

The HTML br element is used to insert a line break in a piece of text. It is an empty element, which means that it does not have a closing tag. The br element is a simple and convenient way to add extra space between lines of text in a webpage, making it easier for users to read the content.

Examples

Here is an example of how the br element can be used in an HTML document:

<p>This is a paragraph of text.<br>
It contains a line break<br>
inserted using the br element.</p>

In this example, the br element is used to insert line breaks between the lines of text in the paragraph. This will cause the text to be displayed as follows:

This is a paragraph of text.
It contains a line break
inserted using the br element.

The br element can also be used to create extra space between elements on a webpage, as shown in this example:

<h1>This is a heading</h1>
<br>
<p>This is a paragraph of text.</p>

This will result with the br element creating a line break between the heading and the paragraph, giving extra space between the two elements. This will cause the webpage to be displayed as follows:

This is a heading

This is a paragraph of text.

Attributes

AttributeDescriptionDeprecated
clearSpecifies where the next line should start after the breakYes

Best Practices

Here are some best practices for using the HTML br element:

  • Use the br element sparingly. Too many line breaks can make your content difficult to read and can also make your webpage look cluttered.
  • Use the br element only to add extra space between lines of text, not to add extra space between words or letters. This is because the br element creates a hard line break, which cannot be adjusted using CSS.
  • Use the p element to create paragraphs of text, and use the br element only to add line breaks within a paragraph. This is because the p element automatically adds extra space between paragraphs, so using the br element in this context is unnecessary.
  • Use the br element only to create extra space between block-level elements, such as headings and paragraphs. Do not use the br element to create extra space between inline elements, such as links or images, as this can cause unexpected behavior and make your content difficult to style.
  • If you need to add extra space between inline elements, use the padding or margin CSS properties instead of the br element. This allows you to adjust the amount of space and create a more consistent and flexible layout for your content.

Use the br element only when it is necessary to add extra space between lines of text or other elements on your webpage.

Accessibility Considerations

Screen readers can have difficulty interpretting the space created using the br element and it is recommended to instead use p elements with proper CSS margin or padding.

Browser Compatibility

ChromeFirefoxSafariInternet ExplorerMicrosoft EdgeOpera
YesYesYesYesYesYes