๐น 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.