<p> : Paragraph element

Introduction

The <p> element in HTML is used to define paragraphs in a web page. It represents a block of text with some separation from the surrounding content. The <p> element automatically adds space above and below the enclosed text, making it visually distinct as a paragraph.

Here’s a simple example of using the <p> element:

Output :

In this example:

  • Two <p> elements are used to create two separate paragraphs.
  • The text inside each <p> element is automatically formatted with space above and below it, making it visually distinct.

Key points about the <p> element:

1. Text Separation: It is primarily used to separate and structure blocks of text into paragraphs.

2. Automatic Formatting: Browsers automatically add space above and below the text enclosed in a <p> element, providing a clear visual separation from other content.

3. Whitespace Handling: Extra whitespace, such as line breaks and spaces, is typically normalized within a <p> element. This means multiple consecutive spaces or line breaks are treated as a single space.

4. Nesting: The <p> element cannot contain block-level elements, but it can contain inline elements and text.

5. CSS Styling: Developers can apply CSS styles to customize the appearance of paragraphs, adjusting aspects such as font size, line spacing, and margins.

In summary, the <p> element is a fundamental HTML element for organizing and presenting text content in a structured manner on a webpage. It plays a key role in maintaining readability and visual hierarchy.

Leave a Comment