HTML Paragraph Element

HTML Paragraph <p> tag is used to define a paragraph in HTML document.

Example

A simple Paragraph element is shown in the following example.

index.html

</>
Copy
<!DOCTYPE html>
<html>
<head>
</head>
<body>
 
    <p>This is a paragraph.</p>
  
</body>
</html>

Note: HTML Paragraph element starts with the tag <p> and ends with an end tag </p>.

Default CSS for Paragraph

By default, following CSS properties are set for a paragraph.

</>
Copy
display: block;
margin-block-start: 1em;
margin-block-end: 1em;

Inline Style for HTML Paragraph

We can change the style of paragraph through inline styling using style attribute.

In the following program, we have set the color as red, and background as black color for the Paragraph element.

index.html

</>
Copy
<!DOCTYPE html>
<html>
<head>
</head>
<body>
 
  <p style="color:red;background:black;">This is a paragraph.</p>
  
</body>
</html>

Apply CSS for a Paragraph

We can apply CSS for all paragraphs using the p tag.

index.html

</>
Copy
<!DOCTYPE html>
<html>
<head>
  
  <style>
    p {
      color:red;
      background:black;
    }
  </style>
  
</head>
<body>
 
  <p>This is a paragraph.</p>
  
</body>
</html>

Conclusion

In this HTML Tutorial, we learned about HTML Paragraph tag and went through different examples that cover defining a Paragraph element, and styling it.