MyInternships.in

HTML Basics

HTML Paragraphs

The paragraph is the workhorse of web text. This page shows how the <p> tag works, how browsers treat spaces and line breaks, and how to control them.


What is an HTML Paragraph?

A paragraph is a block of text defined with the <p> tag. Browsers automatically add space above and below each paragraph, which separates blocks of text visually.

One thing surprises beginners: the browser collapses whitespace. Multiple spaces, tabs, or new lines in your source code are all displayed as a single space. To force a line break or extra space, you use specific tags.

Basic Usage

Two separate paragraphs
Example
<p>This is the first paragraph.</p>
<p>This is the second paragraph.</p>

Example: How Whitespace Collapses

Extra spaces and lines are ignored
Example
<!DOCTYPE html>
<html>
<body>
  <p>This    text     has    many    spaces,
     but the browser shows it as single spaces
     on one flowing line.</p>
</body>
</html>

More Examples

Forcing line breaks with <br>
Example
<p>Roses are red,<br>
Violets are blue,<br>
HTML is fun,<br>
And so are you.</p>
Preserving spacing with <pre>
Example
<pre>
  This text keeps
      its    spaces
  and line breaks
  exactly as typed.
</pre>

Text Spacing Tags

TagEffect
<p>Creates a paragraph with space above and below.
<br>Inserts a single line break inside text.
<hr>Draws a horizontal divider line.
<pre>Preserves whitespace and line breaks exactly.
💡

Use <br> sparingly — only for genuine line breaks like poems or addresses. For spacing between blocks, use separate paragraphs or CSS margins instead.

⚠️

You cannot fix layout with lots of blank lines or spaces in the source. The browser ignores them. Use CSS for spacing and alignment.

Key Takeaways

  • The <p> tag defines a paragraph of text.
  • Browsers collapse multiple spaces and line breaks into one space.
  • Use <br> for a single line break and <pre> to keep exact spacing.
  • Control real spacing with CSS, not blank lines.

Related HTML Topics

Keep learning with these closely related tutorials.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships