Loading

KEYPOINTS

  • It is used to define a paragraph of text within the structure of an HTML document.
  • the <p> element represents the paragraph tag.
  • It is a container tag
  • Paragraph element is defined by <p> opening tag and </p> closing tag in HTML.


Syntax:

<p>content</p>

Attributes:

  • The align attribute in HTML was historically used to set the alignment of various elements, such as paragraphs (<p>), images, and tables, to the left, center, or right. However, the use of the align attribute for styling has been deprecated in favor of CSS, which provides more control and flexibility.

    For instance, instead of using align="center" within a paragraph tag:
    <p style="text-align: center;">This paragraph is centered.</p>

Example:

<!DOCTYPE html>
<html>

  <body>
	<h2>Welcome To Quipo House</h2>
	<!-- Use of <p> tag -->
	<p>This is a paragraph.</p>
  </body>

</html>

Output:

Try it Yourself:


How to use HTML Horizontal tag in paragraph

The <hr> tag in HTML is used to create a horizontal line that visually separates content on a webpage. This line can act as a divider between different sections, paragraphs, or headings, helping to organize and clarify the structure of your content. It’s a simple yet effective way to indicate a shift in topic or to break up large blocks of text. In addition to its default appearance as a solid line, the <hr> tag can be customized with CSS to change its thickness, color, or style, giving you control over how it fits within your design.

The example below shows us how to use <hr> tag in separate paragraphs.

Example:

<!DOCTYPE html>
<html>

<body>
    <h1>Example of hr</h2>
        <h4>This is a heading</h4>
        <p>This is a paragraph.</p>
        <hr>
        <h4>This is a heading</h4>
        <p>This is a paragraph</p>
        <hr>
</body>

</html>

Output:


How to use HTML Break tag in paragraph

The <br> tag in HTML is used to create a line break within text, adding vertical space without starting a new paragraph. It's like hitting the "Enter" key in a word processor, moving the content that follows to a new line while keeping it part of the same block. This tag is especially useful when you want to add a single line break without extra spacing that a new paragraph (<p>) would introduce. For example, you might use the <br> tag in an address, a poem, or any place where you need to control the flow of text with precision.

The example below shows us how to use <br> tag in breaking lines in paragraphs.

Example:

<!DOCTYPE html>
<html>

<body>
    <h1>Example of hr</h2>
        <h4>This is a heading</h4>
        <p>This is a paragraph <br>with line break</p>
</body>

</html>

Output:


How to use HTML <pre> tag in paragraph

The <pre> tag in HTML is used to maintain the exact formatting of text, including spaces, tabs, and line breaks. Unlike other HTML elements, which might compress multiple spaces into a single space or ignore line breaks, the <pre> tag preserves all the whitespace exactly as it appears in the code. This makes it particularly useful for displaying code snippets, poetry, or any text where the layout and indentation are important. By using the <pre> tag, you ensure that your content appears on the webpage just as you intended, without any unexpected changes to its structure.

The example below shows us how to use <pre> tag in preserving spaces and line breaks in paragraphs.

Example:

<!DOCTYPE html>
<html>

<body>
    <h1>Example of pre in writing poems</h2>
        <pre>
            Twinkle, twinkle, little star,
            
            How I wonder what you are!
            
            Up above the world so high,
            
            Like a diamond in the sky.
        </pre>
</body>

</html>

Output: