The two ways to break a line in HTML
HTML has two main ways to create a line break. The <br> tag creates a single line break within text or between elements. The <p> tag (paragraph) creates a larger break with space above and below, and is the standard way to separate blocks of text.
Which one you use depends on what you are trying to do. If you want text to continue on the next line but stay visually close together — like in a poem or an address — use <br>. If you want to separate distinct thoughts or sections, use <p> tags to wrap each paragraph.
Key Takeaways
- The <br> tag creates a single line break and does not need a closing tag — write it as <br> or <br />.
- The <p> tag wraps entire paragraphs and creates larger spacing; always close it with </p>.
- Use <br> for short line breaks within a block of text, and <p> for separating distinct sections.
- Pressing Enter in your HTML code does not create a line break on the webpage — you must use <br> or <p> tags.
Using the <br> tag for a single line break
The <br> tag tells the browser to move to the next line without adding extra space. It is a self-closing tag, which means it does not have a separate closing tag. You can write it as <br> or <br /> — both work the same way.
Here is an example. If you type this in your HTML file:
<p>123 Main Street<br>Springfield, IL 62701</p>
The browser will display the address on two lines, with the street on the first line and the city and state on the second. The text stays inside the same paragraph, so there is no large gap between the lines.
Use <br> for poetry, song lyrics, mailing addresses, or any time you need a line break without the larger spacing that paragraphs create.
Using the <p> tag to separate paragraphs
The <p> tag wraps a complete paragraph of text. It has an opening tag <p> and a closing tag </p>, and the browser automatically adds space above and below the paragraph.
Here is an example:
<p>This is the first paragraph. It contains a complete thought.</p> <p>This is the second paragraph. It starts on a new line with space above it.</p>
The browser will display each paragraph on its own line with visible space between them. This is the standard way to structure text on a webpage because it makes the content easier to read and tells screen readers where one idea ends and another begins.
Why pressing Enter in your code does not create a line break
When you write HTML, pressing Enter to move to a new line in your code file does not create a line break on the webpage. The browser ignores extra spaces, tabs, and line breaks in your source code.
This code:
<p>This is line one This is line two</p>
will display as "This is line one This is line two" all on one line, because there is no <br> tag between them. The Enter key in your editor is only for making your code easier to read — it does not affect how the page looks.
This is why developers often press Enter after opening tags and before closing tags to keep their code organized. The browser sees the code as one continuous line regardless of where the line breaks are in the file.
Combining <br> and <p> tags
You can use both tags together. A <p> tag holds a paragraph, and <br> tags inside it create line breaks within that paragraph.
Here is an example of a poem:
<p>Roses are red,<br> Violets are blue,<br> Sugar is sweet,<br> And so are you.</p>
Each line of the poem appears on its own line, but the whole poem stays in one paragraph with no large gaps between the lines. If you wanted to add another stanza, you would close the first paragraph with </p> and open a new one with <p>.
Common mistakes to avoid
The most common mistake is forgetting to close the <p> tag. If you open a paragraph with <p> but never write </p>, the browser may display your page incorrectly or combine paragraphs that should be separate.
Another mistake is using multiple <br> tags to create space between sections. If you want space between blocks of text, use separate <p> tags instead. Using many <br> tags in a row is harder to maintain and does not follow standard HTML structure.
Do not rely on spaces in your code to create line breaks. If you need a line break on the webpage, use <br> or <p> tags — spaces in your HTML file are ignored by the browser.
Frequently Asked Questions
What is the difference between <br> and <br />?
Both work the same way in modern browsers. <br /> is the older XHTML style with a forward slash, while <br> is the newer HTML5 style. You can use either one — pick one and stay consistent in your code.
Can I use <br> instead of <p> to separate all my paragraphs?
Technically yes, but you should not. Using <p> tags is the correct way because it tells the browser and screen readers that each block is a separate paragraph. Using only <br> tags makes your code harder to read and can cause problems with accessibility and search engines.
How do I create multiple line breaks in a row?
Use multiple <br> tags: <br><br><br>. However, if you want large gaps between sections, it is better to use separate <p> tags instead, because paragraphs are designed for that purpose and are easier to style with CSS later.
Do I need to add a space before the <br> tag?
No. The <br> tag itself creates the line break. You can write text<br> or text <br> — the space before the tag does not matter to the browser, though adding a space can make your code easier to read.