
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 want | What to use | Example |
|---|---|---|
| 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 preserved | white-space: pre-line | A multiline message |
| Existing newlines and repeated spaces preserved | white-space: pre-wrap | Text with meaningful indentation |
| Preformatted content | <pre> | A terminal transcript |
| More space between paragraphs | CSS margin | Article 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 value | Keeps source newlines? | Keeps repeated spaces? | Allows automatic wrapping? |
|---|---|---|---|
normal | No | No | Yes |
nowrap | No | No | No |
pre-line | Yes | No | Yes |
pre-wrap | Yes | Yes | Yes |
pre | Yes | Yes | No |
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 <. 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.
| Problem | What may be happening | What to check |
|---|---|---|
| Source newlines do not appear | Whitespace is collapsing normally | Use <br> or preserve newlines with CSS |
The page shows <br> as text | The tag is escaped or in a code example | Check for <br> and the editor block type |
The page shows \n | A backslash and “n” were entered literally | Check how the string was created |
| Text spills outside its container | Wrapping is disabled or a long string cannot break | Inspect white-space, widths and overflow-wrap |
| Paragraphs have a large gap | Paragraph margins or block spacing | Adjust the relevant CSS |
<wbr> does not force a new line | It provides only an optional break opportunity | Use <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 create a new line?
The character reference 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.