HTML New Line: How to Add Line Breaks Correctly

by .

To add an HTML new line, put the <br> tag wherever you want the next line to begin. Use a separate <p> element when you want a new paragraph.

If your text already contains newline characters, the CSS property white-space: pre-line can preserve them without a break tag after every line.

Here is a simple example:

<p>First line.<br>Second line.</p>

The browser displays “First line.” and “Second line.” as separate lines of text in the same paragraph.

Once you separate those tasks, deciding whether to use <br>, <p> or CSS becomes much clearer.

HTML new line: which method fits your content?

What you wantWhat to useExample
A required break within a paragraph<br>Lines of a poem or address
A separate paragraph<p>The next paragraph of an article
Existing newlines preservedwhite-space: pre-lineA multiline message
Existing newlines and repeated spaces preservedwhite-space: pre-wrapText with meaningful indentation
Preformatted content<pre>A terminal transcript
More space between paragraphsCSS marginArticle typography
An optional place to wrap<wbr>A long filename

Start by making sure the markup describes your content correctly. Once you are happy with that, use CSS to style it.

Adding a line break using <br>

The <br> tag adds a line break at a specific location in text. It is most useful when the location of that break is important.

For example, someone reading a delivery address should be able to view each part on its own line:

<p>
  Example Studio<br>
  18 Orchard Lane<br>
  Dundee<br>
  DD1 1AA
</p>

These pieces of information belong to one group of content. There is no need to convert each line into a separate paragraph.

MDN’s documentation about line breaks explains that <br> is a void element. It does not contain text and must not have an end tag.

Write <br> rather than <br></br>. You will also see <br /> in HTML. Both spellings are accepted by browsers; the forward slash does not affect their behaviour in HTML.

A mailing address does not automatically need an <address> element. That element is for relevant contact information, rather than every address mentioned on a page. Our guide to the address element explains its purpose.

Does pressing Enter produce a visible new line in HTML?

Look at this source code:

<p>First line.
Second line.
Third line.</p>

Under normal whitespace processing, the browser displays one continuous paragraph: “First line. Second line. Third line.” The text can still wrap when it reaches the edge of its container.

Although the source has newlines, the displayed page does not have to show them. CSS usually collapses whitespace so developers can format and organise HTML without affecting how the page appears.

If the breaks belong in the content, include <br>. If you want to keep the existing newlines across a block of text, choose a suitable white-space value.

Separate paragraphs with <p>

A line break continues the same paragraph. A paragraph element defines another paragraph of content:

<p>Your account is ready.</p>
<p>You can now sign in and update your details.</p>

Browsers usually add some vertical distance between paragraphs. Your stylesheet can modify this.

Do not write an entire article inside one <p> and separate its paragraphs with <br><br>. The HTML Standard’s guidance for br reserves it for breaks that belong in the content, such as those within poems and addresses.

Proper paragraphs also give assistive technologies meaningful structure. A page that simply looks like it includes several paragraphs does not necessarily provide the same navigation experience.

See our HTML5 element index for a wider reference to these elements.

Manage paragraph spacing with CSS

If paragraphs appear too close together, adjust their margins:

.article-body p {
  margin: 0 0 1rem;
  line-height: 1.6;
}

Here, margin controls the space after each paragraph. The unitless line-height sets line box height to 1.6 times the font size.

These adjustments are independent of each other. Additional break tags make the spacing harder to manage when the font size or layout changes.

Keep existing newlines with CSS

Imagine you have received a message that already contains meaningful line breaks. You can retain those newlines in your HTML source:

<p class="message">Your order has shipped.
Delivery is expected tomorrow.
Please keep your tracking number.</p>

Now add this CSS to your stylesheet:

.message {
  white-space: pre-line;
}

The newlines are preserved, repeated spaces are collapsed, and long lines can continue to wrap.

Choose pre-wrap when repeated spaces and tabs should also be retained. The differences are documented in MDN’s white-space reference.

CSS valueKeeps source newlines?Keeps repeated spaces?Allows automatic wrapping?
normalNoNoYes
nowrapNoNoNo
pre-lineYesNoYes
pre-wrapYesYesYes
preYesYesNo

For messages or imported plain text, pre-line is generally a good starting point. When the spacing carries meaning, prefer pre-wrap.

Watch the leading spaces in your elements. Preserving whitespace also keeps spaces you entered purely to make the source easier to read.

When to use <pre>

The <pre> element represents preformatted text: content whose layout depends on its original spacing.

<pre>Build started
  Checking files
  Running tests
Build complete</pre>

Spaces and line breaks are preserved by default, and browsers typically display the text in a monospace font.

Long lines could overflow in a narrow window. Apply white-space: pre-wrap to that element if wrapping is acceptable. Alternatively, consider a scrollable container if the original line layout needs to stay intact.

HTML is still parsed inside <pre>. To display markup as text, escape characters such as < as &lt;. The element does not switch HTML parsing off.

Will \n create a new line in HTML?

Entering the two characters \n directly into ordinary HTML does not create a line break:

<p>First line.\nSecond line.</p>

The browser displays the backslash and letter “n”.

JavaScript behaves differently. In a JavaScript string, \n represents a newline character. Whether that character appears as a visible break depends on how the page handles whitespace.

For example:

<p id="status" style="white-space: pre-line;"></p>
const status = document.getElementById("status");
status.textContent = "Upload complete.\nYour file is ready.";

Run this script after the paragraph exists. The string contains a real newline, and pre-line makes it visible.

Using textContent inserts plain text rather than interpreting it as HTML. This approach suits messages submitted by users or retrieved from an API: you do not need to convert their text into markup to preserve its lines.

How to add a new line in WordPress

In an ordinary WordPress Paragraph block:

  • Press Enter to create a new paragraph block.
  • Press Shift + Enter to insert a line break within the current paragraph.

Use a line break for an address or a short verse. For the next paragraph of an article, press Enter.

A Custom HTML block renders HTML. A Code block displays it as an example, so entering <br> into a Code block shows the tag itself.

Preview the page before adding extra breaks. Your theme may simply be applying a larger margin around each paragraph than you expected.

Why is my HTML new line not appearing?

Review the actual markup and the CSS styles applied to its container.

ProblemWhat may be happeningWhat to check
Source newlines do not appearWhitespace is collapsing normallyUse <br> or preserve newlines with CSS
The page shows <br> as textThe tag is escaped or in a code exampleCheck for &lt;br&gt; and the editor block type
The page shows \nA backslash and “n” were entered literallyCheck how the string was created
Text spills outside its containerWrapping is disabled or a long string cannot breakInspect white-space, widths and overflow-wrap
Paragraphs have a large gapParagraph margins or block spacingAdjust the relevant CSS
<wbr> does not force a new lineIt provides only an optional break opportunityUse <br> for a required break

With <wbr>, text can remain on one line if sufficient width is available. That is what the element is designed to allow.

When investigating a layout problem, resize the browser too. A manual break chosen for a wide heading could leave an awkward short line on a phone. Allow natural wrapping unless there is a clear reason to force the break.

Frequently asked questions

Which HTML tag creates a new line?

The HTML line break tag is <br>. Place it wherever you need a new line within the same paragraph or another suitable text container.

Are <br> and <br /> equivalent?

In HTML, both create the same line break. A trailing slash does not turn <br> into a container, and neither spelling needs an end tag. XHTML follows XML syntax rules and uses <br />.

Can &#10; create a new line?

The character reference &#10; inserts a line feed character. Under normal whitespace processing, it does not force a visible break. Use <br> or preserve newlines through CSS.

How do I put a blank line between paragraphs?

Use separate <p> elements and configure their margins in CSS. Do not use empty paragraphs or repeat <br> tags simply to push content further down the page.

Join the discussion.

Some HTML is ok

You can use these tags:
<a href="" title="">
<abbr title="">
<b>
<blockquote cite="">
<cite>
<del datetime="">
<em>
<i>
<q cite="">
<strong>

You can also use <code>, and remember to use &lt; and &gt; for brackets.