🔹 What is the <p>
Tag, And Its Uses?
<p>
Tag in HTML is used to define a single paragraph. Since it is a block-level element, it adds a margin to the spacing on all four sides, which helps in the readability of your content.
This is a paragraph of text.
🧠 Key Features
- Block level element.
- It will give you a default top and bottom margin.
- You cannot add block elements such as
<div>
,<section>
, etc. - It must be closed with
</p>
.
🧪 Examples
✅ Simple Paragraph
This is a basic paragraph.
✅ Paragraph with Formatting
This is bold and italic.
✅ With Line Break
Line one.
Line two.
Line two.
❌ Incorrect Usage
Invalid paragraph placeholder
block inside
block inside
⚠️ Block elements like <div>
should not be placed inside a paragraph tag.
🎨 Styling with Tailwind
You can easily manage the style of your paragraphs using Tailwind, by creating a p tag with the css class; “text-lg leading-relaxed
”
This is a styled paragraph using Tailwind
As a placeholder for a Tailwind styled paragraph.
📌 Best Practices
- You can use one
<p>
tag for a single idea or section of content. - Never place block elements inside a paragraph tag.