Program to see difference between paragraphs & normal text with line break

Description: Write a program that shows the difference between two paragraphs and a single text with line breaks.

Hint:

  • Use two <p> tags for the paragraphs.
  • Use the <br> tag inside one paragraph for the line break.

Paragraphs and line break program

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Paragraph vs line break</title>
</head>
<body>
  <h3>Two paragraphs</h3>
  <p>This is the first paragraph.</p>
  <p>This is the second paragraph.</p>

  <h3>One paragraph with a line break</h3>
  <p>This is the first line.<br>This is the second line.</p>
</body>
</html>

Output in the browser:

Output in the browser

Two paragraphs

This is the first paragraph.

This is the second paragraph.

One paragraph with a line break

This is the first line.
This is the second line.

How it works

  • Each <p> adds a space above and below, so the paragraphs look separate.
  • <br> only moves the text to the next line. The lines stay close, as they are still one paragraph.
  • Use paragraphs for separate ideas, and <br> for things like an address or a poem.

Read HTML Paragraphs.


Learn more about the similar topics:
Tutorials
HTML Headings
HTML Paragraphs
HTML Styles
HTML Formatting
HTML Comments
HTML Symbols
Exercises & Assignments
Program to see difference between paragraphs & normal text with line break
Write a program to create a webpage to print values 1 to 5
Write a program to create a webpage to print your city name in red color.
Write a program to print a paragraph with different font and color.
Write an HTML program to display all six heading levels
Write an HTML program for text formatting (bold, italic, subscript, superscript)
Interview Questions & Answers
How to add comments in HTML?
How to add the copyright symbol to a web page?
What is the difference between strong and b tag in HTML?
What are HTML entities?
What is the difference between inline, internal and external CSS?