FactorPad
Faster Learning Tutorials

HTML br tag

The line break tag creates a carriage return within a block of text. Learning the XML form is worth the extra effort here.
  1. About - Understand the purpose of the br tag.
  2. Syntax - Describe how it is used.
  3. Settings - View required and optional attributes plus default behaviors.
  4. Examples - Review br code examples.
by Paul Alan Davis, September 5, 2018
Updated: December 18, 2018
The line break tag often confuses beginners because it doesn't have a closing tag. Learn more below.

Outline Back Next

~/ home  / tech  / html5  / reference  / html br tag


HTML br tag

Beginner

The <br /> tag's primary purpose is to add a line break within a block of text.

HTML Tags Reference

1. About the HTML br tag

The <br /> tag only occurs in the <body>, so the visible section of the document. From there it is normally found within a paragraph, so in a <p> element.

Its purpose is to add a carriage return, which is also called a line break or new line across programming languages. You might require a break when writing a poem or a mailing address, although the <address> element might be a better option.

As an inline-element, a break can be placed anywhere on a line. It doesn't take up the whole space of its parent element as a block-level element would.

So the <br /> tag is about the display of text, not document structure.

2. Syntax for the HTML p tag

The <br /> element requires only one tag. There are a handful of other single-tag elements, like <meta />, <hr /> and <img />. These may also be referred to as "empty tags".

Unlike other most other tags, the <br /> tag has no attributes. Of course global attributes apply, as they do with all elements.

HTML vs. XML

Technically under HTML5, the tag can be input simply as <br>, but since it is so similar to the XML and XHTML-conforming standard of <br />, I recommend learning the longer form here, especially as you progress towards learning the more advanced markup language XML, the eXtensible Markup Language.

The importance of XML has grown over recent years with the popularity of automated forms of web publishing like blogs and social feeds that connect to databases.

Sample HTML input
<body> <p><strong>Write Poetry. We Wish He Could.</strong></p> <p> If he could write a nice poem,<br /> this sure would be more fun.<br /> The way it's written now,<br /> he won't impress anyone.<br /> </p> <p>:]</p> </body>

HTML code input above will appear as shown below.

Sample HTML output

Write Poetry. We Wish He Could.

If he could write a nice poem,
this sure would be more fun.
The way it's written now,
he won't impress anyone.

:]

3. Settings for the HTML br tag

As with all tags, Global Attributes can always be set.

Attributes and values for the br tag

The <br /> element doesn't have any of its own attributes, or they would be detailed here.

Default behaviors

Each user-agent (browser) has its own stylesheet per se. This dictates how that browser styles each element by default. The Chrome browser styles the <br /> element using the following specifications.

br { display: inline; height: auto; width: auto; }

4. Examples of the HTML br tag

Example 1 - Create a break for an address

The following HTML code will create line breaks for an address block.

<html> <head></head> <body> <p> Doc Brown<br /> 1640 Riverside Drive<br /> Hill Valley, CA </p> </body> </html>

Learning takes practice. Type these lines into a text file, save it with an .html extension and open it in a browser.

After that, start taking notes and writing in HTML to gain experience.


Other Related HTML Content

The <br /> tag sits in a paragraph element, and that sits in the body element.


What's Next?

See what else you can learn for free at our YouTube Channel. Subscribe here.

  • For the complete HTML tag list, click Outline.
  • To learn about the <p> tag, click Back.
  • To see how to insert a horizontal line with the <hr /> tag, click Next.

Outline Back Next

~/ home  / tech  / html5  / reference  / html br tag



 
 
Keywords:
html br tag
html line break
br tag
html br
br element
html br element
break line
html line feed
new line html
html carriage return
line break tag
html br reference
html br tag defaults