Paragraph Tag
<p> tag in HTML stand for paragraph. It serves the purpose of establishing a separate block of text as a paragraph; It is the simplest and frequently used element for adding content in a webpage.
- Organizes text into sections that can be read easily.
- Automatically adds space (margin) before and after the text.
- Help in Search Engine Optimization (SEO) by organizing the content appropriately.
EXAMPLE
Key Features of <p> Tag:
- Block-level Element : It always takes up the entire width and begins on a new line.
- Can Contain Inline Elements : You can also used the inline tags like
<a>,<em>,<strong>,<span>, inside a<p> - Use closing
</p>tag : Your paragraph tag should always be closed. It can be automatically closed by some browsers, but this feature is unreliable. - One idea per paragraph : With the help of this you can read content easily and understand.
- Don’t nest block elements inside
<p>: The block element like<div>,<ul>,<table>, etc , should not go inside a<p>tag,
Paragraph vs Line Break <br>
Paragraph <p>
Uses spacing to begin a new block.
Line Break <br>
The <br> is used to move to the next line inside the same paragraph .
Styling Paragraphs with CSS
We can also apply CSS on the paragraph , with the help of CSS we can change the font, color, etc of paragraph . lets apply inline CSS on the paragraph.
Applying CSS on 'p' Element
Link with Paragraph
In HTML , you can insert link within the paragraph using <a> tags to make specific words or phrases clickable .
Images Within Paragraphs
In HTML , you can insert image within the paragraph using <img> tags .
Superscript and Subscript Within Paragraphs
In HTML , we using superscript and subscript text within a paragraph using <sup> . This is also useful for mathematical notations, chemical formulas, footnotes and more .
Citations Within Paragraphs in HTML
The <cite> tag is used to define the title for a creative work, like book, document, website ,movie or other source . Typically , browsers style it in italic by default. They increase the credibility and meaning of content. HTML provide specific tags like <cite> and <blockquote> to mark citations inside the paragraph.
<blockquote> Tag
If you can quote long sentence then you use the blockquote
Horizontal Line in Paragraph
In HTML, the <hr> is stand for horizontal line . It is frequently used to visually divide sections or content.The <hr> tag is empty tage and does not need a closing tag.
Abbreviations Within Paragraphs
The <abbr> tag helps us to define abbreviations or acronyms.
<span> tag
The <span> tag is inline tag that gives us text fromat. Whenever you use this tag , your text remain in the same line instead of going to the second line . The formatting remains between this tag just applies to it.