The <br> tag is used in HTML to insert a line break in text without starting a new paragraph.
It is useful when you want to divide text into distinct lines while staying within the same block of content.
Structure and syntax of the <br> tag
Basic structure and syntax
The <br> tag is a self-closing tag, which means it does not need a closing tag. Here is its syntax:
<br>It is inserted directly into the content to indicate the placement of the line break.
It is also possible to use the <br> tag in its XHTML syntax: <br />. Both tags are conformant and compatible with the latest version of HTML.
Usage example
Let's take a practical example:
<p>Here is a line of text.<br>And here is another line of text.</p>In this example, a line break is inserted between the two sentences while staying within the same paragraph.
Attributes
The <br> tag has no specific attributes because it simply adds a line break.
Best practices
- Use
<br>only when necessary for simple layout adjustments or to avoid multiple paragraphs. - Avoid using it for complex formatting purposes; prefer CSS to control spacing and alignment.
- For separating blocks of content, consider using the
<p>tag.
Browser compatibility
The <br> tag is supported by all modern browsers.
| Browser | Compatibility |
|---|---|
| Chrome | Yes |
| Firefox | Yes |
| Safari | Yes |
| Edge | Yes |
| Internet Explorer | Yes |