πŸŽ‰ New: Top 75 PHP Interview Questions for 2026 β€” Free for all learners

HTML Paragraphs

P
php Guru
Β· February 20, 2023 Β· 3 min read Β· Updated February 20, 2023

πŸ“Œ Key Takeaways

  • HTML Paragraphs
  • What Are HTML Paragraphs
  • HTML Paragraph Syntax
  • Basic Paragraph Example
  • HTML Automatically Adds Space
  • HTML Ignores Extra Spaces
Advertisement

HTML Paragraphs are used to display blocks of text on a web page.
They help organize content into readable sections.

In this tutorial, you will learn how to create paragraphs, how spacing works, and see examples with output.

What Are HTML Paragraphs

HTML paragraphs are defined using the <p> tag.

They are used to:

  • Display text content
  • Separate blocks of text
  • Improve readability

HTML Paragraph Syntax

Example

<p>This is a paragraph.</p>

Explanation

PartDescription
<p>Opening tag
ContentText inside paragraph
</p>Closing tag

HTML paragraphs, paragraph tag HTML, HTML p tag, HTML text formatting, HTML basics


Basic Paragraph Example

Example Code

<p>This is my first paragraph.</p>
<p>This is my second paragraph.</p>

Output

This is my first paragraph.

This is my second paragraph.


HTML Automatically Adds Space

HTML automatically adds space before and after paragraphs.

Example Code

<p>First paragraph</p>
<p>Second paragraph</p>

Output

First paragraph

Second paragraph


HTML Ignores Extra Spaces

HTML ignores extra spaces and line breaks in code.

Example Code

<p>
This is a paragraph
with extra spaces.
</p>

Output

This is a paragraph with extra spaces.


Line Break Inside Paragraph

To break a line, use <br> tag.

Example Code

<p>This is line one.<br>This is line two.</p>

Output

This is line one.
This is line two.


Horizontal Line with Paragraph

You can separate content using <hr>.

Example Code

<p>Paragraph one</p>
<hr>
<p>Paragraph two</p>

Output

Paragraph one


Paragraph two


Styling Paragraphs

Example Code

<p style="color: blue;">This is a styled paragraph.</p>

Output

This is a styled paragraph. (in blue color)


Aligning Paragraph Text

Example Code

<p style="text-align: center;">Centered paragraph</p>

Output

Centered paragraph (center aligned)


HTML Paragraph vs Heading

Comparison Table

FeatureParagraphHeading
Tag<p><h1> to <h6>
PurposeText contentTitles
ImportanceNormalHigh

Common Mistakes with Paragraphs

MistakeResult
Missing closing tagFormatting issues
Using <br> too muchPoor readability
Adding extra spacesIgnored by browser
Using paragraphs as headingsWrong structure

Multiple Paragraph Example

Example Code

<h1>About HTML</h1><p>HTML is used to create web pages.</p><p>It is easy to learn and widely used.</p>

Output

About HTML

HTML is used to create web pages.

It is easy to learn and widely used.


This page can link to:

  • HTML Headings
  • HTML Text Formatting
  • HTML Tags
  • HTML Elements

Frequently Asked Questions (FAQ)

1. What is a paragraph in HTML?

A paragraph is a block of text defined using the <p> tag.

2. Does HTML support multiple paragraphs?

Yes, you can create multiple paragraphs using multiple <p> tags.

3. How do I add a line break?

Use the <br> tag.

4. Does HTML keep extra spaces?

No, HTML ignores extra spaces.

5. Can I style paragraphs?

Yes, using CSS or the style attribute.

P
php Guru
← Previous Post
HTML Headings
Next Post β†’
HTML Style Attribute

Leave a Reply

Your email address will not be published. Required fields are marked *

Prove your humanity: 7   +   5   =