HOW-TO

How to make a line break and add space in HTML

<br> vs <p>, extra spaces with &nbsp;, space between lines and blocks with CSS, keeping line breaks from pasted text, and fixes when the spacing will not change.

4 min read·

To make a line break in HTML, put a <br> tag where the new line should start: Line one<br>Line two. Pressing Enter in the HTML file does nothing on the page, because browsers collapse every run of spaces, tabs and new lines into one space.

Line break or new paragraph

  • ✓<br> starts a new line inside the same block, with no extra gap. Use it for addresses, poems and lines of a signature: 12 High Street<br>Leeds<br>LS1 4AB.
  • ✓<p>…</p> starts a new paragraph and adds a gap above and below (about one line by default). Use it for separate paragraphs of text.
  • ✓Two <br><br> in a row make a blank line, but a margin in CSS (below) is easier to change later.
  • ✓<br> has no closing tag. <br/> also works; both are valid.

Add extra spaces between words

Typing several spaces shows one. To force more, use the non-breaking space entity: Name:&nbsp;&nbsp;&nbsp;Sam shows three spaces. &nbsp; also keeps two words on the same line, which is useful for 10&nbsp;kg or Mr.&nbsp;Lee.

For indentation or even gaps, CSS is cleaner than a string of &nbsp;: <span style="margin-left: 2em;">indented</span>, or p { text-indent: 2em; } to indent the first line of every paragraph.

Space between lines and blocks

  • ✓Space between lines of text: p { line-height: 1.6; } (1.6 times the font size).
  • ✓Space between paragraphs: p { margin: 0 0 1em; }.
  • ✓Space above one heading: <h2 style="margin-top: 40px;">.
  • ✓Space inside a box, between its border and its text: .card { padding: 16px; }.
  • ✓Even gaps between items in a row or column: .row { display: flex; gap: 12px; }.
  • ✓Letter and word spacing: letter-spacing: 0.05em; and word-spacing: 4px;.

Keep line breaks from pasted text

If you paste a block of text, a list of lines or a code sample, wrap it in <pre>…</pre> to keep every space and new line exactly as typed (it also switches to a monospace font). To keep the line breaks but wrap long lines in the normal font, use CSS instead: <p style="white-space: pre-line;">.

When the break or space does not show

  • ✓Blank lines in the file: the browser ignores them. Use <br> or separate <p> tags.
  • ✓Margins merge: the bottom margin of one paragraph and the top margin of the next collapse into the larger of the two, not the sum. Use padding or gap if you need both.
  • ✓A reset removes spacing: frameworks such as Tailwind set margins on p and headings to 0. Add a class such as mb-4 or space-y-4 on the parent.
  • ✓Inline elements ignore top and bottom margin: a <span> or <a> will not move down with margin-top. Add display: inline-block; or use a block element.
  • ✓Text in a table cell or button will not wrap where you expect: add <br> inside it, or white-space: normal; if a rule set nowrap.
  • ✓Cached file: reload with Ctrl+Shift+R (Cmd+Shift+R on a Mac).

Pages made with AI tools

Pages from Claude, ChatGPT and other tools often use Tailwind, where spacing is a class: mt-8 (margin on top), mb-4 (margin below), p-6 (padding), gap-4 and space-y-4 (gaps between children), leading-relaxed (line height). Change the number in the class instead of adding <br> tags; each step is 4px (mt-8 is 32px).

Share the page as a link

Spacing that looks right on a laptop can look cramped on a phone, so open the page on both before you send it. With FileShare Pro you upload the .html file from the dashboard, copy the link and send it; it opens as a page in any browser and the person opening it needs no account. To fix spacing after you send it, edit the file and upload it to the same link. Related: how to center text in HTML and how to change the font and font size in HTML. Sign up free to share your first page.

Frequently asked

What is the HTML tag for a line break?

<br>. It starts a new line in the same block of text and has no closing tag.

How do I add more than one space in HTML?

Use &nbsp; for each extra space, for example word&nbsp;&nbsp;&nbsp;word, or use CSS margin, padding or word-spacing for larger gaps.

Why does HTML ignore my spaces and new lines?

Browsers collapse runs of spaces, tabs and new lines into one space. Use <br>, <p>, &nbsp;, <pre> or white-space: pre-line to keep them.

Should I use <br> or <p>?

Use <p> for separate paragraphs and <br> for a new line inside one block, such as an address or a poem. For space between blocks, use CSS margin rather than several <br> tags.

Got a page to share?

Drop the file, copy the link — live in seconds, free plan included.

Start sharing free