HTML <br>
Tag
The <br>
tag inserts a single line break within text content. It is an empty element, meaning it has no closing tag. It's primarily used for creating new lines in paragraphs, lists, or any block of text where you need to control line breaks without starting a new paragraph. Itβs very useful when you want to have a specific structure or break text in specific ways.
Syntax
<br>
or
<br />
Attributes
The <br>
tag does not support any specific attributes.
Example
<p>This is the first line.<br>This is the second line, on a new line.</p>
More Examples
Basic Line Breaks in a Paragraph
This example shows how to use <br>
to force line breaks within a paragraph.
<p>This is a long sentence.<br>It is broken into two lines using the <br> tag.<br>This is the third line.</p>
Line Breaks in Lists for Formatting
You can also use <br>
tags inside list items to create visually separated blocks of content.
<ul>
<li>First Item <br> More details about the first item.</li>
<li>Second Item <br> Some extra information on the second item.</li>
</ul>
Using <br>
for Addresses
In addresses, line breaks are essential for properly displaying the address structure.
<address>
CodeLucky Inc.<br>
123 Main Street<br>
Anytown, CA 12345<br>
USA
</address>
Using <br>
in poems
<p>
The woods are lovely, dark and deep,<br>
But I have promises to keep,<br>
And miles to go before I sleep,<br>
And miles to go before I sleep.
</p>
Use of <br>
for Formating Content
<p>
This is the first line. <br><br>
This is the third line. <br>
</p>
Browser Support
The <br>
tag is supported by all major browsers.
Browser | Version |
---|---|
Chrome | All |
Edge | All |
Firefox | All |
Safari | All |
Opera | All |
Notes and Tips
- Use the
<br>
tag sparingly. Overusing<br>
tags can make your HTML harder to read and maintain. - For structural breaks, consider using paragraphs
<p>
or other appropriate block elements. - Avoid using
<br>
for spacing. Use CSS for margins and padding. - While
<br>
and<br />
are both acceptable, the latter is the XHTML-compliant way of writing the tag. It doesn't matter which way you use it for the HTML5 version. - In cases where you need a line break between words but without having the text go to the next line, you can use the
character, which stands for "non-breaking space". - Consider using CSS
white-space: pre-line;
on a container element for controlling line breaks, especially when dealing with text that should respect the line breaks in source content. - The
<br>
tag is an empty element, hence, it does not have any closing tag, meaning<br></br>
is incorrect usage.