Description
The HTML element <p> is used to define a paragraph, which is one of the most used block elements.
- Browsers ignore empty paragraph elements, so do not use empty
<p>elements to add blank lines. Instead, use the<br>element or CSS margins. - Each paragraph starts on a new line with some margins (based on browser-defined styles) above and below the paragraphs, which can be overridden using CSS margins.
The below table summarizes its usage.
| Usage Details | |
| Placement | It is displayed as a Block element. |
| Contents | It can contain Inline elements and text. |
| Tags | Opening tag: required; Closing tag: optional |
| Versions | HTML 2, 3.2, 4, 4.01, 5 |
Syntax
Here is the basic syntax of the <p> element.
<p>...</p>
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element p</title>
</head>
<body>
<p>This is a paragraph.<p>
<p>This is a another paragraph.<p>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <p> element.
| Attribute Type | Details |
| Element-Specific Attributes | The tag <p> has some element-specific attributes listed in the below table. |
| Global Attributes | Like all other HTML tags, the tag <p> supports the HTML Global Attributes. |
| Event Attributes | The tag <p> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <p> element.
| Attribute | Value | Required | Description |
align |
left, right, center, justify | No | Obsolete Specifies the horizontal alignment of the paragraph text. This attribute is no more supported in HTML5, so use the CSS text-align property instead. |
Browser Compatibility
The tag <p> is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 2+
- Firefox 1+
- Apple Safari 1+
- Opera 2.1+