0
0
HtmlHow-ToBeginner · 3 min read

How to Create Line Break in HTML: Simple Guide

To create a line break in HTML, use the <br> tag where you want the break. This tag inserts a new line without starting a new paragraph.
📐

Syntax

The <br> tag is a self-closing tag in HTML that creates a line break. It does not need a closing tag.

  • <br>: Inserts a single line break.
html
<br>
Output
A line break is inserted here.
💻

Example

This example shows how to use the <br> tag to break text into separate lines inside a paragraph.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Line Break Example</title>
</head>
<body>
  <p>This is the first line.<br>This is the second line after a line break.<br>This is the third line.</p>
</body>
</html>
Output
This is the first line. This is the second line after a line break. This is the third line.
⚠️

Common Pitfalls

Some common mistakes when using line breaks in HTML include:

  • Using multiple <br> tags to create space instead of proper CSS margin or padding.
  • Confusing <br> with paragraph tags like <p>, which create separate blocks, not just line breaks.
  • Not closing the <br> tag properly in XHTML (should be <br />), but in HTML5 just <br> is fine.
html
<!-- Wrong: Using multiple <br> for spacing -->
<p>Line one.<br><br><br>Line two.</p>

<!-- Better: Use CSS margin for spacing -->
<p style="margin-bottom: 2rem;">Line one.</p>
<p>Line two.</p>
Output
Line one. Line two. Line one. Line two.
📊

Quick Reference

Remember these tips for line breaks in HTML:

  • Use <br> for a simple line break inside text.
  • Use <p> for separate paragraphs with space.
  • Use CSS for controlling spacing and layout instead of many <br> tags.

Key Takeaways

Use the
tag to insert a line break in HTML text.
Avoid using multiple
tags for spacing; use CSS margins instead.

is self-closing and does not need a closing tag in HTML5.
For separate paragraphs, use

tags instead of
.

Proper use of line breaks improves readability and structure.