A paragraph in HTML is defined using the <p>
tag. It is used to structure text in a webpage, making the content readable and organized.
<p>
Tag:✔ The <p>
tag represents a block-level element, meaning it starts on a new line.
✔ It automatically adds margin (space) before and after the paragraph.
✔ It helps in formatting and structuring textual content.
✔ Multiple paragraphs can be added to separate different sections of text.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Paragraph Example</title>
</head>
<body>
<h1>Introduction to HTML Paragraphs</h1>
<p>This is the first paragraph of text. It provides an introduction to HTML paragraphs.</p>
<p>This is the second paragraph, which continues the explanation and adds more details.</p>
</body>
</html>
✔ Explanation:
<p>
tag creates a new paragraph.
By default, HTML ignores extra spaces and new lines inside a <p>
tag. To create a new line inside a paragraph, use the <br>
tag.
<br>
<p>This is the first line.<br>This is the second line in the same paragraph.</p>
✔ The <br>
tag inserts a line break without creating a new paragraph.
Instead of writing long text in one paragraph, use multiple <p>
tags.
<p>This is a long paragraph that contains multiple ideas without any breaks, making it difficult to read and understand. It is better to use multiple paragraphs instead of writing everything in one block.</p>
<p>This is the first paragraph. It introduces the topic.</p>
<p>This is the second paragraph. It provides additional information.</p>
✔ Splitting text into shorter paragraphs improves readability.
<p>
Inside a <div>
A <div>
(division) can contain multiple paragraphs to group related content.
<div>