The Correct Usage of the HTML P and BR Elements

Creating Line Breaks and Paragraphs with the P and BR Tags

Text displayed in a book
Understanding how to markup text with paragraphs and line breaks.

When learning HTML, two tags that most people learn very early on are the paragraph and line break elements, which are <p> and <br />. These tags put natural breaks in your text so that your webpage's content is easier to read. While these tags are fairly easy to use, but they can also cause some confusion and be misused.

Correct Use of the HTML Paragraph Element

The paragraph element (<p>) is used as a tag pair with the <p> opening the element and the </p> tag closing it.

In writing HTML4 or HTML5, the end tag is technical not required, but it is generally considered a best practice to close this tag. In XHTML, the closing </p> is required.

You would use the paragraph element on a website the same way you would when writing content for off-web needs - when you want to start a new idea or point. Most browsers display paragraphs with one blank line between them. Here is a sample paragraph in HTML:

<p>Now is the time for all good men to come to the aid of their country. The quick brown fox jumped over the lazy sleeping dog.</p>

The paragraph element can be added to an HTML document within the following other elements or tag pairs:
<address>, <blockquote>, <body>, <button>, <center>, <dd>, <div>, <fieldset>, <form>, <iframe>, <li>, <noframes>, <noscript>, <object>, <td>, <th>

The following tags are valid within the pargraph element. These can appear within he <p>...</p> tag pair:
<acronym>, <applet>, <b>, <basefont> (not for HTML5), <big>, <br/>, <button>, <cite>, <code>, <dfn>, <em>, <font>, <i>, <iframe>, <img>, <input>, <kbd>, <label>, <map>, <object>, <q>, <s>, <samp>, <script>, <select>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <textarea>, <tt>, <u>, <var>

Note that some of these tags are not supported in HTML5, namely:
<applet>, <basefont>, <big>, <font>, <strike>

Correct Use of the HTML Line Break Element

The line break element, or <br> tag is a singleton tag—it has no end tag. In XHTML, you must close the tag with a final slash (e.g. <br />), but in HTML (including HTML5) it is not required (e.g. <br>).

The break element is simply a forced line break within the text flow of the web page. You would use it when you want the text to continue on the next line, but that content is not really sepeate ideas or points (which would make them paragraphs). An example of this would be with poetry.

Here is an example of a line break inside a paragraph:

Now is the time for all good men to come to the aid of their country.<br/>
The quick brown fox jumped over the lazy sleeping dog.

The line break tag is valid within the following tags (once again, some of these are not vaild in HTML5):
<a>, <acronym>, <address>, <applet>, <b>, <bdo>, <big>, <blockquote>, <body>, <button>, <caption>, <center>, <cite>, <code>, <dd>, <del>, <dfn>, <div>, <dt>, <em>, <fieldset>, <font>, <form>, <h#>, <i>, <iframe>, <ins>, <kbd>, <label>, <legend>, <li>, <noframes>, <noscript>, <object>, <p>, <pre>, <q>, <s>, <samp>, <small>, <span>, <strike>, <strong>, <sub>, <sup>, <td>, <th>, <tt>, <u>, <var>

The line break tag is a singleton tag, which means that no other tags can be used within it.

Common Misuses of the P and BR Tags

There are some common mistakes that people make with the paragraph and line break elements when marking up a web page

  • Using <br> to change the length of your text line and try to force the text to appear/break in a very specific way.

    This will insure that your pages look great on your browser, but not necessarily on another browser and certainly not on all devices if your site is a responsive website that changes its layout based on different screen sizes. This is because the browsers will automatically put in word wrapping and then when it comes to your <br> will wrap the text again, resulting in short lines and long lines and choppy text. You should always use CSS style sheets to dictate visual styles instead of trying to force layout by adding specific HTML elements..
  • Using <p>&nbsp;</p> to add more space between elements.

    Once again, this is turning to HTML to create visual layout - in this case spacing, instead fo CSS/ This is a common practice of some HTML editors, and while it is not technically wrong, it results in awkward looking HTML and can get really confusing to edit later. It is also not in line with web standards and the seperatation of structure and style. In some cases, using non-breaking spaces inside of otherwise empty paragraph tags can also can result in unexpected spacing in different browsers, as they all seem to interpret this differently. Once again, the best solution to achieve the spacing elements need in your design is to use style sheets.

    Learn more about these and other tags in the HTML Tag Library.

    Edited by Jeremy Girard