HTML Paragraphs

HTML Paragraph Tags Tutorial

Tutorial by: Codes with Pankaj

HTML paragraph tags are used to define blocks of text or paragraphs within web pages. These tags play a key role in organizing textual content for better readability and structure.


Explanation of All HTML Paragraph Tags

1. <p>: The Basic Paragraph Tag

The most common tag used for paragraphs in HTML is the <p> tag. It defines a block of text as a paragraph. Browsers automatically add some margin before and after the text inside <p> tags to make the content easier to read.

Example:

<p>This is a simple paragraph in HTML.</p>

2. Line Breaks within Paragraphs: <br> Tag

The <br> tag is used to insert a line break within a paragraph without starting a new one. It is a self-closing tag and doesn’t require an end tag.

Example:

<p>This is a paragraph. <br> This sentence will appear on the next line within the same paragraph.</p>

3. Preformatted Text: <pre> Tag

The <pre> tag preserves the formatting of the text inside it, such as spaces and line breaks. Unlike normal HTML paragraphs, the <pre> tag does not collapse multiple spaces or line breaks.

Example:

<pre>
This is preformatted text.
   It keeps all spaces and
line breaks as you see here.
</pre>

4. The align Attribute (Deprecated)

Earlier versions of HTML allowed you to align paragraph text using the align attribute (with values such as left, right, center, or justify). However, this attribute has been deprecated in favor of using CSS for alignment.

Example (deprecated):

<p align="center">This paragraph is centered.</p>

Note: Use CSS instead for modern alignment practices.


5. Multiple Paragraphs

You can create multiple paragraphs by using multiple <p> tags. Each new <p> tag creates a distinct paragraph with its own block of text.

Example:

<p>This is the first paragraph.</p>
<p>This is the second paragraph, separate from the first one.</p>

Summary of Paragraph Tags

  • <p>: Defines a paragraph.

  • <br>: Inserts a line break within a paragraph.

  • <pre>: Preserves text formatting, including spaces and line breaks.

  • Deprecated: The align attribute (use CSS instead for text alignment).


This concludes the tutorial on HTML Paragraph Tags by Codes with Pankaj! Paragraphs help create a structured, readable content layout for web pages, and with different tags, you can manage text formatting efficiently.


Last updated