HTML Paragraphs
π Key Takeaways
- HTML Paragraphs
- What Are HTML Paragraphs
- HTML Paragraph Syntax
- Basic Paragraph Example
- HTML Automatically Adds Space
- HTML Ignores Extra Spaces
Table of Contents:
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
| Part | Description |
|---|---|
<p> | Opening tag |
| Content | Text 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
| Feature | Paragraph | Heading |
|---|---|---|
| Tag | <p> | <h1> to <h6> |
| Purpose | Text content | Titles |
| Importance | Normal | High |
Common Mistakes with Paragraphs
| Mistake | Result |
|---|---|
| Missing closing tag | Formatting issues |
Using <br> too much | Poor readability |
| Adding extra spaces | Ignored by browser |
| Using paragraphs as headings | Wrong 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.
Internal Backlinks for phponline.in
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.