📝 Chapter 7: Using the <p>
Tag in HTML
The <p>
tag in HTML is used to define a paragraph. It is a block-level element, meaning it automatically starts on a new line and takes up the full width available.
✅ Basic Syntax
<p>This is a paragraph.</p>
✅ Example: Paragraph in a Web Page
<!DOCTYPE html>
<html>
<head>
<title>Welcome to My Website</title>
</head>
<body>
<p>
The HTML <code><p></code> element inserts a paragraph in the document.
Paragraphs are block-level elements that create the basic structure of a document.
Browsers usually render them with some spacing above and below.
</p>
<p>
Note: Paragraphs cannot contain other block-level elements like another paragraph, div, or heading.
Nesting such elements inside <code><p></code> will result in unexpected behavior.
</p>
</body>
</html>
📚 Important Notes
<p>
tags are used to group sentences into meaningful blocks.- They automatically add top and bottom margin (spacing) in most browsers.
- Do not put block-level tags like
<div>
,<h1>
, or another<p>
inside a paragraph. - You can insert multiple paragraphs one after another, each in its own
<p>
tag.
❌ Incorrect Example
<p>This is wrong <p>This is another paragraph</p> </p>
👉 This is invalid HTML and may break your page layout.
✅ Correct Way
<p>This is the first paragraph.</p>
<p>This is another paragraph.</p>