Paragraph Tag

 

Paragraph Tag

To create well-structured text in your HTML document, the <p> tag is essential for defining paragraphs.

<p> Tag: Defining a Paragraph in HTML

The <p> tag is used to format text into distinct paragraphs. Each paragraph element is separated by automatic empty line spaces above and below the content, providing a clear visual separation. The tag must be closed with its corresponding </p> tag.

<p>
  <!-- Paragraph content -->
</p>

Attributes and Styling

While the <p> tag is straightforward, you can enhance its functionality using various attributes like class or id for CSS styling. You can also include inline styles using the style attribute.

<p class="example" style="color: blue;">
  This is a styled paragraph.
</p>

Best Practices

It's advisable to use the <p> tag for textual content and not for layout control. For layout purposes, consider using HTML5 semantic tags like <section><article>, or CSS techniques.

Dont worry we will look into semantic tags and other techniques later in this tutorial. Here is how you can create a paragraph in html: