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:
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:
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:
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):
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:
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