<p> Tag in HTML
The <p> tag in HTML is used to define a paragraph of text. It is one of the most commonly used tags in HTML to structure text content. Each <p> tag represents a block of text, typically separated by space from other paragraphs. The <p> tag automatically adds some margin or space above and below the paragraph, ensuring that the text is clearly separated.
Key Points on <p> Tag:
- The <p> tag is used for grouping related content into paragraphs.
- It automatically adds space between the paragraph and other content, making the document more readable.
- Paragraphs can contain other inline elements like <strong>, <em>, and <a> for more advanced text formatting.
- The <p> tag is block-level, meaning it occupies the full width of the container, pushing other elements down.
- It is best practice to avoid placing block-level elements (like <div>) inside a <p> tag.
Syntax of <p> Tag:
Syntax Example
<p>Your paragraph text here.</p>
Example of <p> Tag in HTML:
This example demonstrates how to use the <p>
tag to create multiple paragraphs in an HTML document.
Code Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML <p> Tag Example</title>
</head>
<body>
<h1>My Webpage</h1>
<p>This is the first paragraph introduces the page.</p>
<p>The second paragraph discusses the use of paragraphs.</p>
<p>The third paragraph continues the explanation.</p>
</body>
</html>
Output
My Webpage
The first paragraph introduces the page.
The second paragraph discusses the use of paragraphs.
The third paragraph continues the explanation.
The <p>
tag is a simple yet essential part of HTML for creating paragraphs in web pages. It helps in structuring the content and makes it more readable for users. Using paragraphs appropriately can greatly improve the layout and accessibility of your web page.